function TRegister.getCookieStr( RawText: TidHeaderList ) : string;
var
i : integer;
str : string;
begin
if RawText = nil then begin
result := '';
end;
str := '';
for i := 0 to RawText.Count - 1 do begin
if RawText.Names[i] = 'Set-Cookie' then begin
str := str + StringReplace(StringReplace(RawText.Strings[i],'Set-Cookie: ','',[rfReplaceALL]),' path=/','',[rfReplaceALL]);
end;
end;
result := str + ' path=/';
end;
function TRegister.sendRegister:boolean;
var
temp:TstringStream;
tSend:TStringList;
b:string;
idhttp1:tidhttp;
c1:TClientSocket;
image:timage;
send:TStringStream;
myrndNumber:string;
t:tstringlist;
gif1:TGifAnimator;
vcode:string;
c:TDateTime;
begin
image := timage.Create(nil);
gif1 := TGifAnimator.Create(nil);
c1 := TClientSocket.Create(nil);
idhttp1 := Tidhttp.Create(nil);
idhttp1.ProtocolVersion := pv1_1;
idhttp1.HandleRedirects := true;
t := tstringlist.Create;
//t.Append('====================');
//t.Append('-> 开始初始化控件');
//t.Append('====================');
idhttp1.Get(my_parent.siteURL + '/Search/Search.asp');
//t.Append('====================');
//t.Append('-> 首次获取的头信息:');
//t.Append(idhttp1.Response.RawHeaders.Text);
//t.Append('-> 真实COOKIE信息:');
//t.Append(getCookieStr(idhttp1.Response.RawHeaders));
//t.Append('====================');
my_cookie := getCookieStr(idhttp1.Response.RawHeaders);
c := Now;
c := IncDay(c,my_loop);
b := DateTimeToStr(c) ;
b := StringReplace(b,'-','%2D',[rfReplaceALL]);
b := StringReplace(b,':','%3A',[rfReplaceALL]);
b := StringReplace(b,' ','+',[rfReplaceALL]);
my_cookie := StringReplace(my_cookie,'[TIME]',b,[rfReplaceALL]);
//t.Append('====================');
//t.Append('-> 取得COOKIE: ' + my_cookie);
//t.Append('====================');
send := tstringstream.Create('JoinFlag=dkls');
b := StringReplace(my_parent.PubPostHeader,'[DATALENGTH]',IntToStr(send.Size),[rfReplaceALL]);
b := StringReplace(b,'[FILE]',my_parent.DirName + 'User/Register.asp',[rfReplaceALL]);
b := StringReplace(b,'[HOST]',my_parent.HostName,[rfReplaceALL]);
b := StringReplace(b,'[PORT]',INTTostr(my_parent.targetPORT),[rfReplaceALL]);
b := StringReplace(b,'[REFERSH]',my_parent.siteURL + '/User/Register.asp',[rfReplaceALL]);
b := StringReplace(b,'[COOKIE]',my_cookie,[rfReplaceALL]);
b := b + send.DataString;
send.Free;
c1.ClientType := ctBlocking;
c1.Host := my_parent.HostName;
c1.Port := my_parent.targetPORT;
c1.Active := true;
c1.Open;
c1.Socket.SendText(b);
//t.Append('====================');
//t.Append('-> 模拟协议页面请求');
//t.Append('-> 请求数据: ' + b);
//t.Append('====================');
with idhttp1.Request do begin
UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; Maxthon; .NET CLR 1.1.4322)';
AcceptEncoding := 'gzip, deflate';
CacheControl := 'no-cache';
Connection := 'Keep-Alive';
AcceptLanguage := 'zh-cn';
idhttp1.Request.CustomHeaders.Add('Cookie: ' + my_cookie);
end;
b := idhttp1.Get(my_parent.siteURL + '/User/number.asp');
temp := tstringstream.Create(b);
gif1.Image.LoadFromStream(temp);
image.Picture.Bitmap := gif1.Image.Frames[0].Bitmap;
vcode := my_parent.getNumber(image);
image.Free;
gif1.Free;
//t.Append('====================');
//t.Append('-> 获取验证码');
//t.Append('-> 分析值为: ' + vcode);
//t.Append('====================');
b := 'Form_username=' + my_account + '&SubmitFlag=29d98Sasphouseasp8asphnet&JoinFlag=3kkdk&Form_password1=' + my_password + '&Form_password2=' + my_password;
b := b + '&Form_mail=' + my_email + '&Form_Question=我是谁&Form_Answer=我当然是上帝了&Form_homepage=&Form_address=&Form_icq=&Form_oicq=&Form_sex=男';
b := b + '&Form_userphoto=0191&Form_byear=19&Form_bmonth=&Form_bday=&Form_Underwrite=' + StringReplace(StringReplace(my_sign,#13,'%0D',[rfReplaceALL]),#10,'%0A',[rfReplaceALL]) + '&ForumNumber=' + vcode + '&submit=+%C9%EA+%C7%EB+';
send := tstringstream.Create(b);
b := StringReplace(my_parent.PubPostHeader,'[DATALENGTH]',IntToStr(send.Size),[rfReplaceALL]);
b := StringReplace(b,'[FILE]',my_parent.DirName + 'User/Register.asp',[rfReplaceALL]);
b := StringReplace(b,'[HOST]',my_parent.HostName,[rfReplaceALL]);
b := StringReplace(b,'[PORT]',INTTostr(my_parent.targetPORT),[rfReplaceALL]);
b := StringReplace(b,'[REFERSH]',my_parent.siteURL + '/User/Register.asp',[rfReplaceALL]);
b := StringReplace(b,'[COOKIE]',my_cookie,[rfReplaceALL]);
b := b + send.DataString;
send.Free;
c1.ClientType := ctBlocking;
c1.Host := my_parent.HostName;
c1.Port := my_parent.targetPORT;
c1.Active := true;
c1.Open;
c1.Socket.SendText(b);
//t.Append('====================');
// t.Append('-> 发送最后请求');
//t.Append('-> 请求数据: ' + b);
//t.Append('====================');
//t.SaveToFile('c:\log.txt');
end;