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