elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Perl Tk] Finder Paths 0.7
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl Tk] Finder Paths 0.7  (Leído 1,410 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl Tk] Finder Paths 0.7
« en: 8 Abril 2012, 01:56 am »

Un simple programa para buscar los listados de directorios en una pagina.

Una imagen


El codigo

Código
  1. #!usr/bin/perl
  2. #Finder Paths 0.7
  3. #Version Tk
  4. #Coded By Doddy H
  5.  
  6. use Tk;
  7. use Tk::ListBox;
  8. use LWP::UserAgent;
  9. use URI::Split qw(uri_split);
  10. use HTML::LinkExtor;
  11.  
  12. if ( $^O eq 'MSWin32' ) {
  13.    use Win32::Console;
  14.    Win32::Console::Free();
  15. }
  16.  
  17. my $background_fondo = "black";
  18. my $texto_color      = "cyan";
  19.  
  20. my $nave = LWP::UserAgent->new();
  21. $nave->timeout(5);
  22. $nave->agent(
  23. "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
  24. );
  25.  
  26. $ha = MainWindow->new(
  27.    -background => $background_fondo,
  28.    -foreground => $texto_color
  29. );
  30. $ha->title("Finder Paths 0.7 || (C) Doddy Hackman 2012");
  31. $ha->geometry("510x430+20+20");
  32. $ha->resizable( 0, 0 );
  33.  
  34. $ha->Label(
  35.    -text       => "Web : ",
  36.    -font       => "Impact1",
  37.    -background => $background_fondo,
  38.    -foreground => $texto_color
  39. )->place( -x => 30, -y => 20 );
  40. my $pagine = $ha->Entry(
  41.    -text       => "http://localhost:8080/paths",
  42.    -width      => 40,
  43.    -background => $background_fondo,
  44.    -foreground => $texto_color
  45. )->place( -x => 80, -y => 23 );
  46. $ha->Button(
  47.    -text             => "Search",
  48.    -width            => 10,
  49.    -command          => \&search,
  50.    -background       => $background_fondo,
  51.    -foreground       => $texto_color,
  52.    -activebackground => $texto_color
  53. )->place( -x => 330, -y => 23 );
  54. $ha->Button(
  55.    -text             => "Logs",
  56.    -width            => 10,
  57.    -command          => \&ver_logs,
  58.    -background       => $background_fondo,
  59.    -foreground       => $texto_color,
  60.    -activebackground => $texto_color
  61. )->place( -x => 405, -y => 23 );
  62.  
  63. $ha->Label(
  64.    -text       => "Type : ",
  65.    -font       => "Impact1",
  66.    -background => $background_fondo,
  67.    -foreground => $texto_color
  68. )->place( -x => 30, -y => 55 );
  69.  
  70. $ha->Radiobutton(
  71.    -text             => "Fast",
  72.    -value            => "fast",
  73.    -variable         => \$type,
  74.    -background       => $background_fondo,
  75.    -foreground       => $texto_color,
  76.    -activebackground => $texto_color
  77. )->place( -x => 80, -y => 57 );
  78. $ha->Radiobutton(
  79.    -text             => "Full",
  80.    -value            => "full",
  81.    -variable         => \$type,
  82.    -background       => $background_fondo,
  83.    -foreground       => $texto_color,
  84.    -activebackground => $texto_color
  85. )->place( -x => 125, -y => 57 );
  86.  
  87. $ha->Label(
  88.    -text       => "Paths Found",
  89.    -font       => "Impact",
  90.    -background => $background_fondo,
  91.    -foreground => $texto_color
  92. )->place( -x => 200, -y => 110 );
  93. my $paths_list = $ha->Listbox(
  94.    -width      => 70,
  95.    -height     => 13,
  96.    -background => $background_fondo,
  97.    -foreground => $texto_color
  98. )->place( -x => 42, -y => 160 );
  99. my $status_now = $ha->Label(
  100.    -text       => "Status : <None>",
  101.    -font       => "Impact",
  102.    -background => $background_fondo,
  103.    -foreground => $texto_color
  104. )->place( -x => 190, -y => 380 );
  105.  
  106. MainLoop;
  107.  
  108. sub search {
  109.  
  110.    $paths_list->delete( "0.0", "end" );
  111.    $status_now->configure( -text => "Status : Scanning" );
  112.    if ( $type eq "fast" ) {
  113.        simple( $pagine->get );
  114.    }
  115.    if ( $type eq "full" ) {
  116.        escalar( $pagine->get );
  117.    }
  118.    $status_now->configure( -text => "Status : <None>" );
  119. }
  120.  
  121. sub ver_logs {
  122.    if ( -f "paths-logs.txt" ) {
  123.        system("paths-logs.txt");
  124.    }
  125.    else {
  126.        $ha->Dialog(
  127.            -title            => "Error",
  128.            -buttons          => ["OK"],
  129.            -text             => "File Not Found",
  130.            -background       => $background_fondo,
  131.            -foreground       => $texto_color,
  132.            -activebackground => $texto_color
  133.        )->Show();
  134.    }
  135. }
  136.  
  137. sub escalar {
  138.  
  139.    my $co    = $_[0];
  140.    my $code  = toma( $_[0] );
  141.    my @links = get_links($code);
  142.  
  143.    if ( $code =~ /Index of (.*)/ig ) {
  144.        $paths_list->insert( "end", $co );
  145.        savefile( "paths-logs.txt", $co );
  146.        my $dir_found = $1;
  147.        chomp $dir_found;
  148.        while ( $code =~ /<a href=\"(.*)\">(.*)<\/a>/ig ) {
  149.            my $ruta   = $1;
  150.            my $nombre = $2;
  151.            unless ( $nombre =~ /Parent Directory/ig
  152.                or $nombre =~ /Description/ig )
  153.            {
  154.                push( @encontrados, $_[0] . "/" . $nombre );
  155.            }
  156.        }
  157.    }
  158.  
  159.    for my $com (@links) {
  160.        $ha->update;
  161.        my ( $scheme, $auth, $path, $query, $frag ) = uri_split( $_[0] );
  162.        if ( $path =~ /\/(.*)$/ ) {
  163.            my $path1 = $1;
  164.            $_[0] =~ s/$path1//ig;
  165.            my ( $scheme, $auth, $path, $query, $frag ) = uri_split($com);
  166.            if ( $path =~ /(.*)\// ) {
  167.                my $parche = $1;
  168.                unless ( $repetidos =~ /$parche/ ) {
  169.                    $repetidos .= " " . $parche;
  170.                    my $yeah = "http://" . $auth . $parche;
  171.                    escalar($yeah);
  172.                }
  173.            }
  174.            for (@encontrados) {
  175.                $ha->update;
  176.                escalar($_);
  177.            }
  178.        }
  179.    }
  180. }
  181.  
  182. sub simple {
  183.  
  184.    my $code  = toma( $_[0] );
  185.    my @links = get_links($code);
  186.  
  187.    for my $com (@links) {
  188.        $ha->update;
  189.        my ( $scheme, $auth, $path, $query, $frag ) = uri_split( $_[0] );
  190.        if ( $path =~ /\/(.*)$/ ) {
  191.            my $path1 = $1;
  192.            $_[0] =~ s/$path1//ig;
  193.            my ( $scheme, $auth, $path, $query, $frag ) = uri_split($com);
  194.            if ( $path =~ /(.*)\// ) {
  195.                my $parche = $1;
  196.                unless ( $repetidos =~ /$parche/ ) {
  197.                    $repetidos .= " " . $parche;
  198.                    my $code = toma( "http://" . $auth . $parche );
  199.  
  200.                    if ( $code =~ /Index of (.*)</ig ) {
  201.                        my $dir_found = $1;
  202.                        chomp $dir_found;
  203.                        my $yeah = "http://" . $auth . $parche;
  204.                        $paths_list->insert( "end", $yeah );
  205.                        savefile( "paths-logs.txt", $yeah );
  206.                    }
  207.                }
  208.            }
  209.        }
  210.    }
  211. }
  212.  
  213. sub toma {
  214.    return $nave->get( $_[0] )->content;
  215. }
  216.  
  217. sub get_links {
  218.  
  219.    $test = HTML::LinkExtor->new( \&agarrar )->parse( $_[0] );
  220.    return @links;
  221.  
  222.    sub agarrar {
  223.        my ( $a, %b ) = @_;
  224.        push( @links, values %b );
  225.    }
  226. }
  227.  
  228. sub savefile {
  229.    open( SAVE, ">>" . $_[0] );
  230.    print SAVE $_[1] . "\n";
  231.    close SAVE;
  232. }
  233.  
  234. #The End ?
  235.  


« Última modificación: 8 Abril 2012, 02:09 am por Doddy » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Perl] Finder Paths
Scripting
BigBear 0 1,450 Último mensaje 14 Octubre 2011, 15:25 pm
por BigBear
[Perl] Finder Pass 0.3
Scripting
BigBear 0 1,479 Último mensaje 31 Marzo 2012, 22:46 pm
por BigBear
[Perl Tk] Finder Pass 0.4
Scripting
BigBear 0 1,441 Último mensaje 31 Marzo 2012, 22:47 pm
por BigBear
[Perl] Finder Paths 0.6
Scripting
BigBear 0 1,303 Último mensaje 8 Abril 2012, 01:55 am
por BigBear
[Perl] Finder Text 0.2
Scripting
BigBear 0 1,345 Último mensaje 23 Junio 2012, 18:15 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines