使用ClientSocket控件实现CSDN论坛帖子的自动回…
2008-04-09 04:26:49来源:互联网 阅读 ()
使用ClientSocket控件实现CSDN论坛帖子的自动回复
写此文章的目的不是要鼓励大家恶意灌水,而是要了解Http头信息传输的机制及Cookie的一些知识,讲之前大家先看一下下面我在CSDN所截获的回复帖子的Http包信息内容:
typestate=1&Point=0&TopicName=发贴测试,闲人勿进!&Room=1404&Content=rt
//Point:分数0 TopicName:文章标题:发贴测试,闲人勿进!是经过unicode编码的 Content:内容: rt 上面是传递的参数
10.104.9.30(1062)-> //发送方IP及端口
10.104.9.30(80) //接受方IP及端口
POST /Expert/PostNew_SQL.asp HTTP/1.1 //接受页面及HTTP版本
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*
Referer: http://expert.csdn.net/Expert/PostNew.asp?room=1404 //提交的地址
Accept-Language: zh-cn //中文语言
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate //接受压缩格式类型
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) //用户环境
Host: expert.csdn.net //主机名称
Content-Length: 111 //长度:111
Connection: Keep-Alive //保持激活状态
Cache-Control: no-cache //没有使用缓存
Cookie: remenber=0; ASPSESSIONIDAAATSBBS=POHKDGIBFHAMPECBCDHIHBCD; room=0; username=dashi888; speaknum=0; speaktime=2003-5-15 11:56:34; adminok=True; userid=487815; info1=0; m_type=1; aszx=0a727a0323230cd62e4cf5326besba01; mid=476831 //COOKIE的内容
注:用户的Cookie是经过32位加密的,我们要先构造自己要发送的Http包信息
截图如下:
下面是代码部分:
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 Edit6KeyPress(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:=''''连接出错!'''';
errorcode:=0; //出错代码
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
s:string;
begin
succ :=false;
s:=socket.ReceiveText;
if (pos(''''200'''',s)<>0) then //返回信息:200 OK,表示发送成功
begin
StatusBar1.SimpleText:=''''成功!'''';
clientsocket1.Active :=false;
succ :=true;
Button1.Enabled :=true;
end else
begin
StatusBar1.SimpleText:=''''失败!'''';
clientsocket1.active:=true;
succ :=false;
Button1.Enabled :=false;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash