Automatic reply to 9CBS forum posts using ClientSocket controls
Writing this article is not to encourage everyone to maliciously irrigation, but to understand the mechanism of HTTP header information and some knowledge of cookie. In the case of everyone first look at the HTTP package information of the HTTP package information that I intercepted at 9CBS.
TYPESTATE = 1 & Point = 0 & TopicName =% B7% A2% CC% F9% B2% E2% CA% D4% A3% AC% CF% D0% C8% CB% CE% F0% BD% F8% A3% A1 & Room = 1404 & content = RT
// Point: Score 0 TopicName: Article Title: Posting test, idle people do not enter! Is the uncode encoded content: content: The above is the passing parameter
10.104.9.30 (1062) -> // send party IP and port
10.104.9.30 (80) // Acceptor IP and Port Post /Expert/postnew_sql.asp http / 1.1 // Accept page and HTTP version accept: image / gif, image / x-xbitmap, image / jpeg, image / pjpeg, Application / VND.ms-PowerPoint, Application / VND.ms-Excel, Application / Msword, Application / X-Shockwave-Flash, * / * Referr: http://expert.9cbs.net/expert/postnew.asp?room = 1404 // Submit Address ACCEPT-LANGUAGE: ENCENCODEDACCEPT-ENCODING: GZIP, DEFLATE / / Accept Compact Format Type USER-Agent: Mozilla / 4.0 (compatible; msie 6.0; Windows NT 5.0) // User Environment Host: Expert.9cbs.net // Host Name Content-Length: 111 // Length: 111Connection: Keep-Alive / / Keep Activation Cache-Control: No- cache // no cache Cookie: remenber = 0; ASPSESSIONIDAAATSBBS = POHKDGIBFHAMPECBCDHIHBCD; room = 0; username = dashi888; speaknum = 0; speaktime = 2003% 2D5% 2D15 11% 3A56% 3A34; adminok = True; userid = 487815; INFO1 = 0; M% 5FTYPE = 1; aszx = 0A727A0323230CD62E4CF5326BESBA01; MID = 476831 // cookie content
Note: The user's cookie is 32-bit encrypted, we must first construct the HTTP package information you have to send.
Screenshot below:
Below is the code section:
UNIT SUBMIT;
Interface
Uses Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs, SCKTComp, NMURL, Stdctrls, Comctrls, ExtCtrls
type TForm1 = class (TForm) url: TNMURL; ClientSocket1: TClientSocket; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Label4: TLabel; Edit4: TEdit; Label5: TLabel ; Button1: TButton; Button2: TButton; StatusBar1: TStatusBar; memo2: TMemo; Memo1: TMemo; Label6: TLabel; Label7: TLabel; Label8: TLabel; Edit5: TEdit; Edit6: TEdit; Label9: TLabel; Edit7: TEdit; Button3 : TButton; Timer1: TTimer; Button4: TButton; Timer2: TTimer; Button5: TButton; procedure Button1Click (Sender: TObject); procedure ClientSocket1Error (Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); procedure ClientSocket1Read (Sender: TObject; Socket: TCustomWinSocket); procedure Button2Click (Sender: TObject); procedure Edit4KeyPress (Sender: TObject; var Key: Char); procedure Edit5KeyPress (Sender: TObject; var Key: Char); procedure Edi t6KeyPress (Sender: TObject; var Key: Char); procedure Edit7KeyPress (Sender: TObject; var Key: Char); procedure Timer1Timer (Sender: TObject); procedure Button3Click (Sender: TObject); procedure Button4Click (Sender: TObject); procedure Timer2Timer (Sender: TObject); procedure ClientSocket1Connect (Sender: TObject; Socket: TCustomWinSocket); procedure FormShow (Sender: TObject); procedure Button5Click (Sender: TObject); private {Private declarations} TopicID, startID, EndID: integer; DelayTime: Integer; Succ: Boolean; Procedure Senddata (); Procedure Buildhttphead (); Public {public Declarations} END; VAR FORM1: TFORM1
IMPLEMENTATION
{$ R * .dfm}
procedure TForm1.Button1Click (Sender: TObject); begin clientsocket1.Active: = true; Button1.Enabled: = false; BuildHttpHead (); end; procedure TForm1.ClientSocket1Error (Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode : Integer; begin statusbar1.simpletext: = 'connection error! '; Errorcode: = 0; // Error code end;
Procedure TForm1.ClientSocket1read (SENDER: TOBJECT; SOCKET: TCUSTOMWInsocket); var s: string; begin succ: = false; s: = socket.recetext; if (POS ('200', s) <> 0) THEN // Return Information: 200 ok, indicating that the send success begin statusbar1.simpletext: = 'success! '; Clientsocket1.active: = false; succ: = true; button1.enabled: = true; end else begin statusbar1.simpletext: =' Failed! '; Clientsocket1.active: = true; SUCC: = false; button1.enabled: = false;
END;
Procedure TFORM1.BUTTON2CLICK (Sender: TOBJECT); begin close;
procedure TForm1.Timer1Timer (Sender: TObject); begin DelayTime: = strtoint (trim (edit7.text)); timer1.Interval: = DelayTime; timer1.Enabled: = True; clientsocket1.Active: = true; SendData; // send Data end;
procedure TForm1.SendData; var i: integer; begin EndID: = StrToInt (trim (edit6.text)); TopicID: = StrToInt (trim (edit4.text)); if TopicID Procedure TForm1.Button3Click (Sender: TOBJECT); Begin Button3.enabled: = false; startID: = StrtOINT (Trim (edit5.text)); edit4.text: = INTOSTR (STARTID); Timer1Timer; END; procedure TForm1.Button4Click (Sender: TObject); begin timer1.Enabled: = false; clientsocket1.Active: = false; Button3.Enabled: = true; end; procedure TForm1.BuildHttpHead; var sendp, sends, sendc: string; begin // http header information sends: = 'post /expert/reply.asp http / 1.1' # 13 # 10; sends: = sends accept: image / gif, image / x-xbitmap, image / jpeg, image / pjpeg , Application / Vnd.ms-PowerPoint, Application / VND.ms-Excel, Application / Msword, Application / X-ShockWave-Flash, * / * ' # 13 # 10; Sends: = Sends ' Accept-Language: zh- CN ' # 13 # 10; sends: = sends ' content-type: Application / X-www-form-urlencoded ' # 13 # 10; sends: = sends ' accept-encoding: gzip, deflate ' # 13 # 10; sends: = sends 'user-agent: mozilla / 4.0 (compatible; msie 6.0; windows nt 5.0)' # 13 # 10; sends: = sends 'Host: Expert.9cbs.net' # 13 # 10; Sends: = sends 'cache-control: no-cache' # 13 # 10; // Constructs cookie information if edit1.text <> '' Then Begin Url.inputString: = Trim (edit1.text); sendp: = 'username =' url.Encode; // unicode encoded sendc: = '9cbsname =' url.encode; end; if edit2.text <> '' Then Begin Url.inputString: = Trim (Edit2.Text); Sendp : = Sendp '; userid =' url.encode; sendc: = sendc '& 9cbspassword =' url.encode; end; if edit3.text <> 'Then Begin url.inputstring: = Trim (edit3.text); sendp: = sendp '; aszx =' url.encode; end; sends: = sends 'cookie:' sendp # 13 # 10; // Sended content URL.InputString: = TRIM ( edit4.text); sendc: = sendc '& Topicid =' url.Encode; url.InputString: = trim (memo1.Text); sendc: = sendc '& ReplyContent =' url.Encode; sendc: = sendc '& xmlReply = AAAAA '; Sends: = Sends 'Content-Length:' INTOSTR (Length) # 13 # 10; sends: = sends # 13 # 10 # 13 # 10 sendc; memo2.lines. Clear; memo2.Lines.Add (sends); clientsocket1.Socket.SendText (sends); // transmitting end; procedure TForm1.ClientSocket1Connect (Sender: TObject; Socket: TCustomWinSocket); begin BuildHttpHead (); // a connection success Send END; Procedure TForm1.FormShow (Sender: TOBJECT); begin succ: = false; // is successful end; Procedure tform1.button5click (sender: TOBJECT); begin button1.enabled: = true; clientsocket1.active: = false; End. The focus of the article is to construct the HTTP header information section, set up the server IP: 211.157.102.25, 9CBS server IP, port is 80