当前位置:编程学习 > C/C++ >>

xmd5 c++查询代码

 

#include <winsock2.h>

#include <iostream.h>

#include <windows.h>

#include <wininet.h>

#include <string.h>

#include <stdio.h>

#include <stdlib.h>

#include <process.h>

#include"string.h"

#include <iostream.h>

#pragma comment(lib,"WS2_32.lib")

 

#define MAX 50000

char str[10000][5000];

char string[10000][5000];

void readfile( );

int num;

void main()

{

int RET;

SOCKET sc;

WSADATA wsaData;

SOCKADDR_IN scAddr;

HOSTENT * ht;

char Buffer[MAX] = {0};

printf("****************** xmd5.com网站md5密码查询******************\n");

 

readfile( );

 

FILE *fHtmlData;

if((fHtmlData=fopen("d:\\save-xmd5.txt","w"))==NULL)

{printf("can not open file2\n");exit(0);}

//fHtmlData = fopen("d:\\readweb.txt", "w");

//printf("总共%d个\n",num);

//char szPage[500] = "GET /getmd5api.aspx?q=c75b7ef7915803f9 HTTP/1.1\r\nHost: www.cmd5.com\r\n\r\n";

printf("\n开始查询并把结果保存在d盘根目录下的save-xmd5.txt中......\n\n");

 

for(int c=0;c<num;c++)

{ char Buffer[MAX] = {0};

 

char szPage[6000]="\0";

//"GET /md5/md5check.asp?md5pass=baf56627478ec76a HTTP/1.1\r\n"

//"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*\r\n"

//"Referer: http://www.xmd5.org/\r\n"

//"Accept-Language: zh-cn\r\n"

//"Accept-Encoding: gzip, deflate\r\n"

// "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com) )\r\n"

// "Host: www.xmd5.org\r\n"

// "Connection: Keep-Alive\r\n"

// "Cookie: AJSTAT_ok_times=1; AJSTAT_ok_pages=47; AJSTAT_ok_times=1; ASPSESSIONIDQASCTSDD=OENPPCBBCIMIMOPNFONANNJO; ASPSESSIONIDQATCSSDC=JNDJIGBBCMDMDLEDELCLENOL\r\n"

//"\r\n\r\n\r\n";

// char szPage[1000] = "GET /md5/md5check.asp?md5pass=eff9d7295bfc800a HTTP/1.1\r\n Host: xmd5.org\r\n\r\n";

//char szPage[500] = "GET /showthread.php?t=44643 HTTP/1.1\r\nHost: bbs.pediy.com\r\n\r\n";

 

memset(string[c], '\0', sizeof(string));

strcpy(string[c],"GET /md5/md5check.asp?md5pass=");

strcat(string[c],str[c]);

strcat(string[c]," ");

strcat(string[c]," HTTP/1.1\r\n");

strcat(string[c],"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*\r\n");

strcat(string[c],"Referer: http://www.xmd5.org/\r\n");

strcat(string[c],"Accept-Language: zh-cn\r\n");

strcat(string[c],"Accept-Encoding: gzip, deflate\r\n");

strcat(string[c],"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com) )\r\n");

strcat(string[c],"Host: www.xmd5.org\r\n");

strcat(string[c],"Connection: Keep-Alive\r\n");

strcat(string[c],"Cookie: AJSTAT_ok_times=1; AJSTAT_ok_pages=47; AJSTAT_ok_times=1; ASPSESSIONIDQASCTSDD=OENPPCBBCIMIMOPNFONANNJO; ASPSESSIONIDQATCSSDC=JNDJIGBBCMDMDLEDELCLENOL\r\n");

 

strcat(string[c],"\r\n\r\n\r\n");

printf("正在查询%s...\n",str[c]);

 

strcpy(szPage,string[c]);

 

WSAStartup(0x0202, &wsaData);

sc = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0);

ht = gethostbyname("www.xmd5.org");

 

scAddr.sin_port = htons(80);

scAddr.sin_family = AF_INET;

scAddr.sin_addr.s_addr = *(unsigned long *)ht->h_addr_list[0];

 

connect(sc, (SOCKADDR *)&scAddr, sizeof(scAddr));

send(sc, szPage, lstrlen(szPage), 0);

RET = recv(sc, Buffer, MAX, 0);//让它返回值,以便检测函数是否调用成功

 

if(RET<1)

{printf("\n服务器出现问题,没有连接成功,请按任意键退出\n");

getchar();

exit(0);

}

 

 

printf("返回内容%s:\n\n",Buffer);

 

//****************我们把信息写入文件*****************************//

 

//for (int i=0; i<RET; i++)//选择密码答案并开始写入文件;

//{

// fputc(Buffer[i], fHtmlData);

//}

// fputc('\n', fHtmlData);

//延迟,等待页面出现,若太快,则不能用commview重新构建TCP会话的HTML版本

int m=0;

while(Buffer[m]!='=')

{m=m+1;

}

m=m+1;

 

while(Buffer[m]!=13)

{

fputc(Buffer[m], fHtmlData);

m=m+1;

}

fputc('\n', fHtmlData);

// fclose(fHtmlData);

Sleep(4000);

WSACleanup();

}//大for循环;

 

 

printf("\n查询完毕,请按任意键退出.\n");

getchar();

exit(0);

}//main()函数

 

void readfile( )

{ int m=0;

char ch;

FILE *fp1;

printf("请托入md5密码txt文件:\n");

char str007[500];

gets(str007);

 

if((fp1=fopen(str007,"r"))==NULL)

{printf("can not open file1\n");exit(0);}

 

ch=fgetc(fp1);

 

while(ch!=EOF)

{ int n=0;

while(ch!=10&&ch!=13&&ch!=EOF)

{

str[m][n++]=ch;

ch=fgetc(fp1);

}//读完一行

 

str[m][n]='\0';//读完一行

//printf("%s\n",str[m]);

m=m+1;

ch=fgetc(fp1);//读下一行

 

}

num=m;//读完文件

printf("总共%d个数据:\n",num);

 

for(int p=0;p<m;p++)

{printf("%s\n",str[p]);

}

 

fclose(fp1);//关闭文件

}

 

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,