VC submits webpage form-automatic comment (1)

Source: Internet
Author: User

Some time ago, after carefully reading an HTTP protocol, I wrote such an automated comments test program. Below are my study notes for this study experiment:

I. preparations:

1. Local Environment: Windows XP SP3, 10 m ADSL Optical Fiber

2. Development Tool: WildPackets OmniPeek V5.1.4

Visual C ++ 6.0

Netpas eight horses free VPN proxy (avoid IP address seizure)

FlexEdit V2.3.1871 (temporarily retain text)

3. webpage program: LBS Version 2.0.313

Ii. analyze data packets:

1. Open the LBS V2.0.313 blog program and you can see the following comments (first look for the ones without verification code !)

 

2. Set the OmniPeek filter type:

 

3. Click "Start packet capture" and manually comment once to capture the data packet. The following red lines are useful:

4. Actual raw data packet content:

5. After being parsed by OmniPeek, view the following content:

6. Check the first three fields and the last three fields. We can analyze them and the comment is actually

POST/blog/comment/asp? Act = save & logid = 3567 HTTP/1.1

E_ubb = true & e_autourl = true & e_smilies = true & comm_username = % E5 % A4 % A9 % E4 % BD %

BF & comm_password = & message = www. ****** .net.cn

After the analysis is complete, we began to prepare the POST data packet with the SOCKET!

/*************************************** * ********************************* Use SOCKET, automatic POST form and comment/* by Koma 2009.9.6/* http://blog.csdn.net/wangningyu /********************* **************************************** * **********/# include "stdafx. h "# include" stdio. h "# include" winsock2.h "# pragma comment (lib," ws2_32.lib ") int main (int argc, char * argv []) {SOCKADDR_IN saServer; LPHOS TENT lphostent; WSADATA wsadata; SOCKET hsocket; int nRet; char * host_name = "www. ******. com "; char * req =" POST/blog/comment. asp? Act = save & logid = 3560 HTTP/1.0 \ r \ n "" Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd. ms-excel, application/vnd. ms-powerpoint, application/msword, application/QVOD, application/QVOD, */* \ r \ n "" Referer: http: // www. ******. com/blog/article. asp? Id = 3560 \ 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; POTU (RR: 28031409: 0: 5497353); SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 );. net clr 2.0.50727; CBA) \ r \ n "" Host: www. ******. com \ r \ n "" Content-Length: 114 \ r \ n "" Connection: Keep-Alive \ r \ n" "Cookie: babyhashkey =; babyuserid =; ASPSESSIONIDACBRSQBC = AFHPMPGBBCGPDDDNEDKGJHEJ \ r \ n "" e_ubb = true & e_autourl = true & e_smilies = true & comm_username = % E5 % A4 % A9 % E4 % BD % BF & comm_password = & message = www. * ***** .net.cn "; // initialize the SOCKET if (WSAStartup (MAKEWORD (), & wsadata) printf (" An error occurred while initializing the SOCKET! "); Lphostent = gethostbyname (host_name); if (lphostent = NULL) printf (" lphostent is empty! "); Hsocket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); saServer. sin_family = AF_INET; saServer. sin_port = htons (80); saServer. sin_addr = * (LPIN_ADDR) * lphostent-> h_addr_list); // connect nRet = connect (hsocket, (LPSOCKADDR) & saServer, sizeof (SOCKADDR_IN) using SOCKET )); if (nRet = SOCKET_ERROR) {printf ("An error occurred while establishing the connection! "); Closesocket (hsocket); return 0;} // use SOCKET to send nRet = send (hsocket, req, strlen (req), 0); if (nRet = SOCKET_ERROR) {printf ("An error occurred while sending the data packet! "); Closesocket (hsocket);} char Dest [3000]; nRet = 1; while (nRet> 0) {// receives the returned data packet nRet = recv (hsocket, (LPSTR) dest, sizeof (Dest), 0); if (nRet> 0) Dest [nRet] = 0; else Dest [0] = 0; // display the returned data packet size and content printf ("\ nconverted ed bytes: % d \ n", nRet); printf ("Result: \ n % s", Dest );} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.