18,356
社区成员
发帖
与我相关
我的任务
分享
CString TempHead;
TempHead += "POST /member.php?mod=register&inajax=1 HTTP/1.1\r\n";
TempHead += "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n";
TempHead += "Referer: http://127.0.0.1/member.php?mod=register\r\n";
TempHead += "Accept-Language: zh-cn\r\n";
TempHead += "Content-Type: multipart/form-data; boundary=---------------------------7da9c24180124\r\n";
TempHead += "UA-CPU: x86\r\n";
TempHead += "Accept-Encoding: gzip, deflate\r\n";
TempHead += "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)\r\n";
TempHead += "Host: 127.0.0.1\r\n";
TempHead += "Content-Length: 879\r\n";
TempHead += "Connection: Keep-Alive\r\n";
TempHead += "Cache-Control: no-cache\r\n";
TempHead += "Cookie: zkzD_2132_sid=41Ymwi; zkzD_2132_lastvisit=1289185316; zkzD_2132_lastact=1289188945%09forum.php%09ajax; zkzD_2132_onlineusernum=2; zkzD_2132_sendmail=1\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='regsubmit'\r\n";
TempHead += "yes\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='formhash'\r\n";
TempHead += "5968679d\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='referer'\r\n";
TempHead += "http://127.0.0.1/\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='activationauth'\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='username'\r\n";
TempHead += "fuck04\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='password'\r\n";
TempHead += "123456\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='password2'\r\n";
TempHead += "123456\r\n";
TempHead += "-----------------------------7da9c24180124\r\n";
TempHead += "Content-Disposition: form-data; name='email'\r\n";
TempHead += "1@1.com\r\n";
TempHead += "-----------------------------7da9c24180124--\r\n";
wPort = 80;
m_httpConnection = m_inernetSession.GetHttpConnection("127.0.0.1", wPort);
m_httpfile = m_httpConnection->OpenRequest(m_httpConnection->HTTP_VERB_POST, "/member.php?mod=register");
if (NULL == m_httpfile)
{
return;
}
m_httpfile->AddRequestHeaders(TempHead);
bool SendRes = m_httpfile->SendRequest();
if (false == SendRes)
{
Say("SendRequest Error");
return;
}
else
{
m_Sended = true;
}
DWORD Ret = 0;
m_httpfile->QueryInfoStatusCode(Ret);
//400-499 Request Error
//500-599 Sever Error
char Temp[100];
sprintf(Temp, "The Request Status is %ld", Ret);
Say(Temp);
CTestHttpDlg *InP = reinterpret_cast<CTestHttpDlg*>(lpParam);
while (1)
{
Sleep(10);
if (true == InP->m_Sended)
{
DWORD Lenth = InP->m_httpfile->GetLength();
bool Res = InP->m_httpfile->Read(InP->m_RecvBuff, 62999);
/*bool Res = InP->m_httpfile->Read(InP->m_RecvBuff, Lenth);*/
if (true == Res)
{
InP->Say(InP->m_RecvBuff);
}
else
{
InP->Say("InternetReadFile Error");
}
InP->m_Sended = false;
}
}
TempHead += "POST /member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&inajax=1 HTTP/1.1\r\n";
TempHead += "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n";
TempHead += "Referer: http://127.0.0.1/member.php?mod=logging&action=login\r\n";
TempHead += "Accept-Language: zh-cn\r\n";
TempHead += "Content-Type: application/x-www-form-urlencoded\r\n";
TempHead += "UA-CPU: x86\r\n";
TempHead += "Accept-Encoding: gzip, deflate\r\n";
TempHead += "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)\r\n";
TempHead += "Host: 127.0.0.1\r\n";
TempHead += "Content-Length: 106\r\n";
TempHead += "Connection: Keep-Alive\r\n";
TempHead += "Cache-Control: no-cache\r\n";
TempHead += LoginCookie; //加入翻译好的COOKIE
TempHead += "\r\n";
TempHead += "fastloginfield=username&username=fuck05&password=123456&quickforward=yes&handlekey=ls&questionid=0&answer=\r\n";
wPort = 80;
m_httpConnection = m_inernetSession.GetHttpConnection("127.0.0.1", wPort);
m_httpfile = m_httpConnection->OpenRequest(m_httpConnection->HTTP_VERB_POST, "/member.php?mod=logging&action=login");
if (NULL == m_httpfile)
{
return;
}
m_httpfile->AddRequestHeaders(TempHead);
bool SendRes = m_httpfile->SendRequest();
void CMyRegDlg::OnBnClickedButton1()//get cookie
{
// TODO: 在此添加控件通知处理程序代码
//构建登陆表单数据
char *action="/d/upload/";
char *headers="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\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)\r\n"
"Host: 192.168.0.21\r\n"
"Connection: Keep-Alive\r\n\r\n";
CString szHeaders(headers);
// szHeaders=headers;//.Format (headers,nReadLength,sid);
CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,action,NULL,1,NULL,NULL,INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_AUTO_REDIRECT);
pFile->SendRequest(szHeaders,NULL,NULL);
szHeaders.ReleaseBuffer ();
CString header("");//获取登陆结果中header
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF,header,0);
pFile->Close();
delete pFile;
int i=header.Find ("Set-Cookie: ");
if(i>=0)
{
i+=12;
cookie1_value=header.Mid ( i,header.Find (";",i)-i);
int j=header.Find ("Set-Cookie: ",i);
if(j>=0)
{
j+=12;
cookie2_value=header.Mid (j,header.Find (";",j)-j);
}
}
header.ReleaseBuffer ();
UpdateData(FALSE);//更新
}
void CMyRegDlg::OnBnClickedButton2()//get formhash
{
// TODO: 在此添加控件通知处理程序代码
int nReadLength =0;
//构建登陆表单数据
char *action="/d/upload/register.php?infloat=yes&handlekey=register&inajax=1&ajaxtarget=fwin_content_register";
char *headers="Accept: */*\r\n"
"Accept-Language: zh-cn\r\n"
"Referer: http://127.0.0.1/d/upload/\r\n"
"Accept-Encoding: gzip, deflate\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"
"Host: 127.0.0.1\r\n"
"Connection: Keep-Alive\r\n"
"Cookie: %s\r\n\r\n";
CString szHeaders;
szHeaders.Format (headers,cookie1_value,cookie2_value);
CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET,action,NULL,1,NULL,NULL,INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_AUTO_REDIRECT);
pFile->SendRequest(szHeaders,NULL,NULL);
szHeaders.ReleaseBuffer ();
CString data("");//获取登陆结果页面
char szBuff[1025];
while(1)
{
nReadLength = pFile->Read(szBuff, 1024);
if(nReadLength==0) break;
szBuff[nReadLength]='\0';
data=data+szBuff;
}
pFile->Close();
delete pFile;
int i=data.Find ("formhash");
if(i>=0)
{
i+=17;
formhash_value=data.Mid ( i,data.Find ("\"",i)-i);
UpdateData(NULL);
}
data.ReleaseBuffer ();
}
void CMyRegDlg::OnBnClickedButton3()//go to register
{
// TODO: 在此添加控件通知处理程序代码
//构建登陆表单数据
char *action="/d/upload//register.php?regsubmit=yes&inajax=1";
char *headers="Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\r\n"
"Referer: http://127.0.0.1/d/upload/index.php\r\n"
"Accept-Language: zh-cn\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
// "Accept-Encoding: gzip, deflate\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n"
"Host: 127.0.0.1\r\n"
"Content-Length: %d\r\n"
"Connection: Keep-Alive\r\n"
"Cache-Control: no-cache\r\n"
"Cookie: %s; %s\r\n";
char *form1="formhash=%s";
char *form2="&referer=http%3A%2F%2F127.0.0.1%2Fd%2Fupload%2findex.php&handlekey=register&activationauth=&username=test2&password=test&password2=test&email=test2@mail.com®submit=%CC%E1%BD%BB";
CString formdata;
formdata.Format (form1,formhash_value);
formdata.Append (form2);
int nReadLength=formdata.GetLength ();
CString szHeaders;
szHeaders.Format (headers,nReadLength,cookie1_value,cookie2_value);
CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,action,NULL,1,NULL,NULL,INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_AUTO_REDIRECT);
pFile->SendRequest(szHeaders,(LPVOID)formdata.GetBuffer (),nReadLength);
szHeaders.ReleaseBuffer ();
formdata.ReleaseBuffer ();
CString data("");//获取登陆结果页面
char szBuff[1025];
while(1)
{
nReadLength = pFile->Read(szBuff, 1024);
if(nReadLength==0) break;
szBuff[nReadLength]='\0';
data=data+szBuff;
}
pFile->Close();
delete pFile;
int i=data.Find ("CDATA[");
// CDATA[该用户名已经被注册]
if(i>=0)
{
i+=6;
AfxMessageBox(data.Mid (i,data.Find ("]",i)-i));
}
//if(data.Find ("该用户名已经被注册")) AfxMessageBox("已经存在!");
m_data.SetWindowTextA (data);
data.ReleaseBuffer ();
}
CString TempHead;
//请求一个页面的报文
TempHead += "GET HTTP/1.1\r\n";
TempHead += "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n";
TempHead += "Accept-Language: zh-cn\r\n";
TempHead += "Accept-Encoding: gzip, deflate\r\n";
TempHead += "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)\r\n";
TempHead += "Host: 192.168.1.82\r\n";
TempHead += "Connection: Keep-Alive\r\n";
wPort = 80;
m_httpConnection = m_inernetSession.GetHttpConnection("192.168.1.82", wPort);
m_httpfile = m_httpConnection->OpenRequest(m_httpConnection->HTTP_VERB_POST, "");
if (NULL == m_httpfile)
{
return;
}
m_httpfile->AddRequestHeaders(TempHead);
bool SendRes = m_httpfile->SendRequest();
if (false == SendRes)
{
Say("SendRequest Error");
return;
}
else
{
m_Sended = true;
}
DWORD Ret = 0;
m_httpfile->QueryInfoStatusCode(Ret);
//400-499 Request Error
//500-599 Sever Error
char Temp[100];
sprintf(Temp, "The Request Status is %ld", Ret);
Say(Temp);
DWORD CTestHttpDlg::RecvProc(LPVOID lpParam)
{
CTestHttpDlg *InP = reinterpret_cast<CTestHttpDlg*>(lpParam);
while (1)
{
Sleep(10);
if (true == InP->m_Sended)
{
bool Res = InP->m_httpfile->Read(InP->m_RecvBuff, 62999);
if (true == Res)
{
InP->Say(InP->m_RecvBuff);
}
}
}
return 0;
}
bool Res = InP->m_httpfile->Read(InP->m_RecvBuff, 62999);
if (true == Res)
{
InP->Say(InP->m_RecvBuff);
}
m_httpfile = m_httpConnection->OpenRequest(m_httpConnection->HTTP_VERB_GET,
"",
NULL,
1,
NULL,
NULL,
INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_AUTO_REDIRECT);
TempHead += "POST /member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&inajax=1 HTTP/1.1\r\n";
TempHead += "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n";
TempHead += "Referer: http://127.0.0.1/\r\n";
TempHead += "Accept-Language: zh-cn\r\n";
TempHead += "Content-Type: application/x-www-form-urlencoded\r\n";
TempHead += "UA-CPU: x86\r\n";
TempHead += "Accept-Encoding: gzip, deflate\r\n";
TempHead += "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)\r\n";
TempHead += "Host: 127.0.0.1\r\n";
TempHead += "Content-Length: 107\r\n";
TempHead += "Connection: Keep-Alive\r\n";
TempHead += "Cache-Control: no-cache\r\n";
TempHead += "Cookie: zkzD_2132_sid=J77K23; zkzD_2132_lastvisit=1289266892; zkzD_2132_lastact=1289270496%09index.php%09; zkzD_2132_sendmail=1; zkzD_2132_onlineusernum=1\r\n";
TempHead += "fastloginfield=username&username=fuck05&password=123456&quickforward=yes&handlekey=ls&questionid=0&answer=\r\n";