程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> xmd5 c++查詢代碼

xmd5 c++查詢代碼

編輯: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);//關閉文件

}

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved