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

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


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


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl] Emails Extractor 0.2
« en: 27 Diciembre 2013, 15:35 pm »

Un simple script en Perl para buscar direcciones de correo en :

  • Un archivo de texto cualquiera
  • Una pagina
  • Usando un dork en google para scanear todas las paginas encontradas con el dork
  • Lo mismo que el anterior pero en bing

El codigo.

Código
  1. #!usr/bin/perl
  2. #Email Extractor 0.2
  3. #(C) Doddy Hackman 2013
  4. #Credits : Regex based on
  5. #http://stackoverflow.com/questions/15710275/print-email-addresses-to-a-file-in-perl
  6. #Thanks to motherconfessor & amon
  7.  
  8. use LWP::UserAgent;
  9. use URI::Escape;
  10.  
  11. my $nave = LWP::UserAgent->new;
  12. $nave->agent(
  13. "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
  14. );
  15. $nave->timeout(10);
  16.  
  17. my $buscador = qr/[A-Z0-9._%+-]+\@[A-Z0-9.-]+\.[A-Z]{2,4}/i
  18.  ;    # Thanks to motherconfessor & amon
  19. my @emails;
  20.  
  21. head();
  22.  
  23. if ( $ARGV[0] eq "-file" ) {
  24.  
  25.    print "\n[+] Opening file ...\n";
  26.  
  27.    if ( -f $ARGV[1] ) {
  28.  
  29.        my $code = openfile( $ARGV[1] );
  30.  
  31.        while ( $code =~ /($buscador)/g ) {
  32.            my $email = $1;
  33.            push( @emails, $email );
  34.        }
  35.  
  36.        my @emails = repes(@emails);
  37.  
  38.        print "\n[+] Mails Found : " . int(@emails) . "\n";
  39.  
  40.        for (@emails) {
  41.            savefile( $ARGV[2], $_ );
  42.        }
  43.  
  44.    }
  45.    else {
  46.        print "\n[-] File not found\n";
  47.    }
  48.  
  49. }
  50. elsif ( $ARGV[0] eq "-google" ) {
  51.  
  52.    print "\n[+] Searching in Google ...\n";
  53.  
  54.    my @links = google( $ARGV[1], $ARGV[2] );
  55.  
  56.    print "[+] Scanning [" . int(@links) . "] pages ...\n";
  57.  
  58.    for my $ink (@links) {
  59.        my $code = toma($ink);
  60.  
  61.        while ( $code =~ /($buscador)/g ) {
  62.            my $email = $1;
  63.            push( @emails, $email );
  64.        }
  65.  
  66.    }
  67.  
  68.    my @emails = repes(@emails);
  69.  
  70.    print "\n[+] Mails Found : " . int(@emails) . "\n";
  71.  
  72.    for (@emails) {
  73.        savefile( $ARGV[2], $_ );
  74.    }
  75.  
  76. }
  77. elsif ( $ARGV[0] eq "-bing" ) {
  78.  
  79.    print "\n[+] Searching in Bing ...\n";
  80.  
  81.    my @links = bing( $ARGV[1], $ARGV[2] );
  82.  
  83.    print "[+] Scanning [" . int(@links) . "] pages ...\n";
  84.  
  85.    for my $ink (@links) {
  86.        my $code = toma($ink);
  87.  
  88.        while ( $code =~ /($buscador)/g ) {
  89.            my $email = $1;
  90.            push( @emails, $email );
  91.        }
  92.  
  93.    }
  94.  
  95.    my @emails = repes(@emails);
  96.  
  97.    print "\n[+] Mails Found : " . int(@emails) . "\n";
  98.  
  99.    for (@emails) {
  100.        savefile( $ARGV[3], $_ );
  101.    }
  102.  
  103. }
  104. elsif ( $ARGV[0] eq "-page" ) {
  105.  
  106.    my $code = toma( $ARGV[1] );
  107.  
  108.    print "\n[+] Loading page ...\n";
  109.  
  110.    while ( $code =~ /($buscador)/g ) {
  111.        my $email = $1;
  112.        push( @emails, $email );
  113.    }
  114.  
  115.    my @emails = repes(@emails);
  116.  
  117.    print "\n[+] Mails Found : " . int(@emails) . "\n";
  118.  
  119.    for (@emails) {
  120.        savefile( $ARGV[2], $_ );
  121.    }
  122.  
  123. }
  124. else {
  125.    sintax();
  126. }
  127.  
  128. copyright();
  129.  
  130. # Functions
  131.  
  132. sub bing {
  133.  
  134.    my ( $a, $b ) = @_;
  135.    for ( $pages = 10 ; $pages <= $b ; $pages = $pages + 10 ) {
  136.        my $code =
  137.          toma( "http://www.bing.com/search?q=" . $a . "&first=" . $pages );
  138.  
  139.        while ( $code =~ /<h3><a href="(.*?)"/mig ) {
  140.            push( @founds, $1 );
  141.        }
  142.    }
  143.    my @founds = repes( cortar(@founds) );
  144.    return @founds;
  145. }
  146.  
  147. sub google {
  148.    my ( $a, $b ) = @_;
  149.    my @founds;
  150.    for ( $pages = 10 ; $pages <= $b ; $pages = $pages + 10 ) {
  151.        $code = toma(
  152.            "http://www.google.com.ar/search?hl=&q=" . $a . "&start=$pages" );
  153.        while ( $code =~ /(?<="r"><. href=")(.+?)"/mig ) {
  154.            my $url = $1;
  155.            if ( $url =~ /\/url\?q\=(.*?)\&amp\;/ ) {
  156.                push( @founds, uri_unescape($1) );
  157.            }
  158.        }
  159.    }
  160.    my @founds = repes( cortar(@founds) );
  161.    return @founds;
  162. }
  163.  
  164. sub cortar {
  165.    my @nuevo;
  166.    for (@_) {
  167.        if ( $_ =~ /=/ ) {
  168.            @tengo = split( "=", $_ );
  169.            push( @nuevo, @tengo[0] . "=" );
  170.        }
  171.        else {
  172.            push( @nuevo, $_ );
  173.        }
  174.    }
  175.    return @nuevo;
  176. }
  177.  
  178. sub toma {
  179.    return $nave->get( $_[0] )->content;
  180. }
  181.  
  182. sub savefile {
  183.  
  184.    if ( $_[0] eq "" ) {
  185.        open( SAVE, ">>logs.txt" );
  186.    }
  187.    else {
  188.        open( SAVE, ">>" . $_[0] );
  189.    }
  190.  
  191.    print SAVE $_[1] . "\n";
  192.    close SAVE;
  193. }
  194.  
  195. sub openfile {
  196.    open my $FILE, q[<], $_[0];
  197.    my $word = join q[], <$FILE>;
  198.    close $FILE;
  199.    return $word;
  200. }
  201.  
  202. sub repes {
  203.    my @limpio;
  204.    foreach $test (@_) {
  205.        push @limpio, $test unless $repe{$test}++;
  206.    }
  207.    return @limpio;
  208. }
  209.  
  210. sub sintax {
  211.    print "\n[+] Sintax : $0 <options> <logs>\n";
  212.    print "\n[+] Examples : \n\n";
  213.    print "[+] $0 -file test.txt logs.txt\n";
  214.    print "[+] $0 -google 50 mailist logs.txt\n";
  215.    print "[+] $0 -bing 50 mailist logs.txt\n";
  216.    print "[+] $0 -page http://localhost/index.php logs.txt\n";
  217. }
  218.  
  219. sub head {
  220.    print "\n-- == Email Extractor 0.2 == --\n";
  221. }
  222.  
  223. sub copyright {
  224.    print "\n-- == (C) Doddy Hackman 2013 == --\n\n";
  225.    exit(1);
  226. }
  227.  
  228. #The End ?
  229.  

Mostraria un ejemplo de uso pero puedo tener problemas cuando el script devuelve como 500 mails ajenos claramente para spam xD.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Extractor de sprites
Juegos y Consolas
Meta 1 3,032 Último mensaje 19 Octubre 2004, 11:38 am
por Arcangel
url extractor?
Programación Visual Basic
elrecar 1 1,304 Último mensaje 17 Septiembre 2007, 22:24 pm
por Hendrix
url extractor
Programación Visual Basic
elrecar 0 1,241 Último mensaje 6 Octubre 2007, 05:11 am
por elrecar
Extractor Web
Programación Visual Basic
traviatØ 2 1,587 Último mensaje 12 Febrero 2009, 04:21 am
por traviatØ
Ventilador (extractor) Torre
Hardware
B€T€B€ 9 14,962 Último mensaje 2 Agosto 2022, 01:05 am
por B€T€B€
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines