The test URL is: http://www.exam8.com/
Test URL ip:222.73.24.32
Test Account: Lzh_5
Password: 123456789
First of all to determine the submission form information, I use the grab Bag tool grabbed the post package, and then write the program to simulate the sending process, the implementation of the login process.
Precautions:
1. Be sure to follow the packet to send the message, even the space, the number of lines to be the same;
2. No verification code for the Web page of the demo login;
Code:
Post Submission Form request Account #include<stdio.h> #include <string> #include <winsock2.h> #include <windows.h> #include <iostream> #include <fstream> #pragma comment (lib, "Ws2_32.lib") #define Max 20480using namespace Std;int Main () {int num,sum; SOCKET s; Wsadata wsa;struct sockaddr_in Serv;char Sndbuf[max], Rcvbuf[max]; WSAStartup (Makeword (2, 1), &WSA), if ((s = socket (af_inet, sock_stream, 0)) <0) {perror ("socket error!"); Exit (1);} memset (&serv,0,sizeof (serv)); serv.sin_family = Af_inet;serv.sin_port = htons;//serv.sin_addr.s_addr = * ((int *) *host_addr->h_addr_list); serv.sin_addr. S_un. S_ADDR = inet_addr ("222.73.24.32"), if (Connect (s, (struct sockaddr *) &serv, sizeof (serv))) <0) {perror ("connet Error! "); Exit (1);} memset (sndbuf, 0, Max), memset (rcvbuf, 0, max);//Header information strcat (SNDBUF, "POST"); strcat (Sndbuf, "/inc/check.asp http/1.1\r\n"); strcat (Sndbuf, "x-requested-with:xmlhttprequest\r\n"); Strcat (Sndbuf, "accept-language:zh-cn\r\n"); strcat (Sndbuf, "Referer:http://reg.exam8.com/"); strcat (Sndbuf, "\ r \ n"), strcat (Sndbuf, "Accept: */*\r\n"), strcat (Sndbuf, "content-type:application/ X-www-form-urlencoded\r\n "); Strcat (Sndbuf," Accept-encoding:gzip, deflate\r\n "); Strcat (Sndbuf," user-agent: mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; trident/5.0; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Esobisubscriber 1.0.0.40; MAAR;. net4.0c;. net4.0e; maxthon/3.0) \ r \ n "), strcat (Sndbuf," host:reg.exam8.com\r\n "), strcat (Sndbuf," content-length:149\r\n "); Strcat ( Sndbuf, "connection:keep-alive\r\n"), strcat (Sndbuf, "cache-control:no-cache\r\n"); Strcat (Sndbuf, "cookie:referrer =http%3a//www.baidu.com/s%3fwd%3d%25e8%2580%2583%25e8%25af%2595%25e5%2590%25a7%26rsv_spt%3d1%26issp%3d1%26f% 3d3%26rsv_bp%3d0%26rsv_idx%3d2%26ie%3dutf-8%26tn%3dmaxthon2%26rsv_sug3%3d3%26rsv_sug4%3d126%26rsv_sug1%3d1% 26oq%3dkaoshi%26rsp%3d0%26rsv_sug5%3d0; hm_lvt_80e97646f045b0632f81239c03c83492=1415795254,1415797440,1415889057; AspsessionidaAqsatds=lhobckmckeknebehllhmphab\r\n "), strcat (Sndbuf," \ r \ n "), strcat (Sndbuf," comeurl=http%3a//\r\n "); Strcat ( Sndbuf, "user.exam8.com®username=lzh_5®userpassword=123456789®pwdconfirm=123456789&[ Email protected]&checkbox1=&action=reg ");p UTS (SNDBUF); if (num = Send (S,sndbuf,max, 0)) <0) {perror ("Send error!"); Exit (1);} Puts ("Send success!\n"); sum = recv (S, rcvbuf, max-1, 0);//If the RCVBUF storage space is reduced, then Copyif (sum>0) {puts ("ok!") is divided into several times; printf ("% S ", rcvbuf);} Puts ("\nread success!\n"); Closesocket (s); system ("pause"); WSACleanup (); return 0;}
Operation Result:
1. Form information submitted to the website
2. Return information for Web pages
3. Return information upon successful application
4. Run this program to return information here
C + + Implementation Request Account---Send post submission form packets