最新消息:

VC socket 实现post提交~

C/C++ admin 3153浏览 0评论

DWORD WINAPI Start(LPVOID lParam)
{
CPostDlg *p = (CPostDlg *)lParam;
SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sock == SOCKET_ERROR)
{
p->MessageBox(“创建套接字失败~”);
return 0;
}
SOCKADDR_IN addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(80);
char url[20] = “192.168.10.104″;

addr.sin_addr.S_un.S_addr = inet_addr(“192.168.10.104″);
int ret =connect(sock, (SOCKADDR *)&addr, sizeof(SOCKADDR_IN));
if(ret == SOCKET_ERROR)
{
p->MessageBox(“连接失败~”);
return 0;
}
char buffer[4096];
char pwd[] = “fuckhacker”;
int len = strlen(pwd) + 21;
sprintf(buffer, “POST /webshell1.php HTTP/1.1rn”
“Content-Type: application/x-www-form-urlencodedrn”
“Host: 192.168.10.104rn”
“Content-Length: %drn”
“rn”
“password=%s&doing=login”,
len,
pwd);
ret = send(sock, buffer, sizeof(buffer), 0);
if(ret == SOCKET_ERROR)
{
p->MessageBox(“发送失败~”);
return 0;
}
memset(buffer, 0, sizeof(buffer));
ret = recv(sock, buffer, sizeof(buffer), 0);
if(ret == SOCKET_ERROR)
{
p->MessageBox(“接受失败~”);
return 0;
}
CString buf(buffer);
if(buf.Find(“Success”, 0) != -1)
p->MessageBox(“密码正确~”);
else
p->MessageBox(“密码错误~”);
return 0;
}

转载请注明:爱开源 » VC socket 实现post提交~

您必须 登录 才能发表评论!