今天在一个群里看到了模拟发包谈到了wininet,于是记起前段时间搞的winhttp和libcurl+openssl。然后又想起php和py等模拟发包十行八行。
而c/c++的确那么多行,心里感觉不公平。
就想到之前,为了一个http代理到处找winhttp,貌似也没发现现成的可用的,或者都多少有点小毛病,不能拿来就用。而且也注意到了winhttp不支持s5代理
于是就又找libcurl和openssl,网上教编译openssl的教程很多,但是貌似也没有可以拿来就用的,记得当时还编译了一晚上。
来吧,虽然是小东西,但是总比烂在硬盘里好,虽然意义不大,但是f12的所有的基本全能满足,也免的需要的人再去重新寻找了。
winhttp 支持https 支持http代理 (可带用户密码) 。
#include "read_winhttp.h" #define DEMO 3 int main() { #if DEMO == 1 //multipart/form-data char* proxy = NULL; char* user = NULL; char* pass = NULL; char* url = "https://ip.cn/"; int mode = 3; //1/2/3 GET/POST/multipart/form-data BOOL refirect = TRUE; //自动重定向 char* cookie = NULL; char* data = "aa=11&bb=22"; int data_len = strlen(data); char* upload_source = "filename"; char* upload_filename = "1.jpg"; char* upload_type = "image/jpeg"; char* upload_buffer = "aa"; int len_upload_buffer = strlen(upload_buffer); WCHAR* w_add_request_headers[] = { L"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", L"Referer: https://bbs.pediy.com/", NULL}; #elif DEMO == 2 //POST char* proxy = NULL; char* user = NULL; char* pass = NULL; char* url = "https://ip.cn/"; int mode = 2; //1/2/3 GET/POST/multipart/form-data BOOL refirect = TRUE; //自动重定向 char* cookie = NULL; char* data = "aa=11&bb=22"; int data_len = strlen(data); char* upload_source = NULL; char* upload_filename = NULL; char* upload_type = NULL; char* upload_buffer = NULL; int len_upload_buffer = 0; WCHAR* w_add_request_headers[] = { L"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", L"Referer: https://bbs.pediy.com/", NULL}; #elif DEMO == 3 //GET char* proxy = NULL; char* user = NULL; char* pass = NULL; char* url = "https://ip.cn/"; int mode = 1; //1/2/3 GET/POST/multipart/form-data BOOL refirect = TRUE; //自动重定向 char* cookie = NULL; char* data = NULL; int data_len = 0; char* upload_source = NULL; char* upload_filename = NULL; char* upload_type = NULL; char* upload_buffer = NULL; int len_upload_buffer = 0; WCHAR* w_add_request_headers[] = { L"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", L"Referer: https://bbs.pediy.com/", NULL}; #endif string strHeader = ""; string strBody = ""; if (read_winhttp(proxy, user, pass, url, mode, refirect, cookie, data, data_len, upload_source, upload_filename, upload_type, upload_buffer, len_upload_buffer, w_add_request_headers,strHeader, strBody)) { puts(strHeader.c_str()); puts(strBody.c_str()); } return 1; }
libcurl+openssl 支持https 支持http代理(可带用户密码) 支持s5代理(可带用户密码)
#include <windows.h> #include <stdio.h> #include "http/readhttp.h" int main(int argc, CHAR* argv[]) { BOOL bSuccess = FALSE; int retCode = 0; char* header = NULL; char* body = NULL; //普通get bSuccess = read_http(NULL,NULL, NULL, NULL, 0, "https://ip.cn/", NULL,0, NULL,NULL,NULL, NULL, 0, NULL, NULL,NULL, retCode, header, body); //普通post bSuccess = read_http(NULL, NULL, NULL, NULL, 1, "https://ip.cn/", "aaa=1&bb=2", strlen("aaa=1&bb=2"), NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, retCode, header, body); //普通put bSuccess = read_http(NULL, NULL, NULL, NULL, 4, "https://ip.cn/", "aaa=1&bb=2", strlen("aaa=1&bb=2"), NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, retCode, header, body); //上传文件不带其他参数 bSuccess = read_http(NULL, NULL, NULL, NULL, 2, "https://ip.cn/", NULL, 0, "userfile", "C:\\Users\\DELL\\Desktop\\666.jpg", NULL, NULL, 0, NULL, NULL, NULL, retCode, header, body); //上传文件并带其他参数 bSuccess = read_http(NULL, NULL, NULL, NULL, 2, "https://ip.cn/", "aaa=1&bb=2", strlen("aaa=1&bb=2"), "userfile", "C:\\Users\\DELL\\Desktop\\666.jpg", NULL, NULL, 0, NULL, NULL, NULL, retCode, header, body); //上传文件的内存并带其他参数 bSuccess = read_http(NULL, NULL, NULL, NULL, 2, "https://ip.cn/", "aaa=1&bb=2", strlen("aaa=1&bb=2"), "userfile", NULL, "1.jpg", "jpg文件内存", strlen("jpg文件内存"), NULL, NULL, NULL, retCode, header, body); if (bSuccess) { printf("retCode = %d\n", retCode); puts(header); puts(body); free(header); free(body); } system("pause"); return 0; }
注意:里面的静态lib文件绝对没有掺假,原样编译的源码,可放心使用!!!(由于体积过大debug的lib都删除了)
2020安全开发者峰会(2020 SDC)议题征集 中国.北京 7月!
最后于 1天前 被mlgbwoai编辑 ,原因: lib太大。。上传不了