Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/bin/perl
- # DH Spider 0.5
- #(C) Doddy Hackman 2016
- #Credits : Regex based on
- #http://stackoverflow.com/questions/15710275/print-email-addresses-to-a-file-in-perl
- #Thanks to motherconfessor & amon
- #http://doddyhackman.webcindario.com/?tipo=perl&id=137
- use DH_Searcher;
- use LWP::UserAgent;
- use IO::Socket::SSL;
- use Getopt::Long;
- use Color::Output;
- Color::Output::Init;
- use Try::Tiny;
- my @agents = (
- 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0',
- 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14',
- 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36',
- 'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0',
- 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.8pre) Gecko/20070928 Firefox/2.0.0.7 Navigator/9.0RC1',
- 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))',
- 'Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.14',
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27'
- );
- my $buscador = qr/[A-Z0-9._%+-]+\@[A-Z0-9.-]+\.[A-Z]{2,4}/i; # Thanks to motherconfessor & amon
- GetOptions(
- "google" => \$google,
- "bing" => \$bing,
- "dork=s" => \$dork,
- "count=i" => \$count,
- "filename=s" => \$filename,
- "page=s" => \$page,
- "savefile=s" => \$savefile
- );
- head();
- if ($google) {
- if($dork ne "" && $count ne "") {
- dh_spider($dork,$count,"","google");
- } else {
- printear("[-] Use dork and count to scan in google\n");
- }
- }
- elsif ($bing) {
- if($dork ne "" && $count ne "") {
- dh_spider($dork,$count,"","bing");
- } else {
- printear("[-] Use dork and count to scan in google\n");
- }
- }
- elsif ($filename) {
- if(-f $filename) {
- dh_spider("","",$filename,"filename");
- } else {
- printear_rojo("[-] File $filename not found\n");
- }
- } elsif($page) {
- if($page ne "") {
- dh_spider_single($page);
- }
- } else {
- sintax();
- }
- copyright();
- # Functions
- sub dh_spider_single {
- my $page = shift;
- my $contador = "0";
- my $algo = 0;
- my @emails_found;
- printear_logo("[+] Searching emails in page ...\n\n");
- my $code = toma($page);
- while ( $code =~ /($buscador)/g ) {
- my $email = $1;
- push( @emails, $email );
- printear_titulo("[+] $page : ");
- printear_azul("$email\n");
- $algo = 1;
- $contador++;
- push(@emails_found,$email);
- }
- if($algo ne "1") {
- printear_titulo("[-] $page : ");
- printear_rojo("Emails not found\n");
- }
- $algo = 0;
- printear("\n[+] Emails Found : ");
- print "$contador\n";
- if($savefile && $contador > 0) {
- my @emails = repes(@emails_found);
- for my $email(@emails) {
- chomp $mail;
- savefile($savefile,$email);
- }
- printear("\n[+] Logs $savefile saved\n");
- }
- printear_logo("\n[+] Finished\n");
- }
- sub dh_spider {
- my($dork,$count,$filename,$option) = @_;
- my $contador = "0";
- my $algo = 0;
- my @links;
- my @emails_found;
- my $searcher = DH_Searcher->new();
- if($option eq "filename") {
- printear("[+] Opening file : ");
- print "$filename\n\n";
- @links = open_file($filename);
- } elsif($option eq "bing") {
- printear("[+] Service : ");
- print "Bing\n";
- printear("[+] Dork : ");
- print "$dork\n";
- printear("[+] Count : ");
- print "$count\n\n";
- printear_logo("[+] Searching pages ...\n\n");
- @links = $searcher->search_bing($dork,$count*10);
- } elsif($option eq "google") {
- printear("[+] Service : ");
- print "Google\n";
- printear("[+] Dork : ");
- print "$dork\n";
- printear("[+] Count : ");
- print "$count\n\n";
- printear_logo("[+] Searching pages ...\n\n");
- @links = $searcher->search_google($dork,$count*10);
- }
- printear("[+] Links found : ");
- print int(@links)."\n\n";
- printear_logo("[+] Searching emails ...\n\n");
- for my $link(@links) {
- chomp $link;
- my $code = toma($link);
- while ( $code =~ /($buscador)/g ) {
- my $email = $1;
- push( @emails, $email );
- printear_titulo("[+] $link : ");
- printear_azul("$email\n");
- $algo = 1;
- $contador++;
- push(@emails_found,$email);
- }
- if($algo ne "1") {
- printear_titulo("[-] $link : ");
- printear_rojo("Emails not found\n");
- }
- $algo = 0;
- }
- printear("\n[+] Emails Found : ");
- print "$contador\n";
- if($savefile && $contador > 0) {
- my @emails = repes(@emails_found);
- for my $email(@emails) {
- chomp $mail;
- savefile($savefile,$email);
- }
- printear("\n[+] Logs $savefile saved\n");
- }
- printear_logo("\n[+] Finished\n");
- $searcher->destroy();
- }
- # More Functions
- sub toma {
- my $page = shift;
- my $contenido = "";
- if($page ne "") {
- try {
- my $nave = LWP::UserAgent->new(ssl_opts => {verify_hostname => 0,SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE});
- $nave->agent( $agents[ rand @agents ] );
- $nave->timeout($timeout);
- $contenido = $nave->get($page)->content;
- } catch {
- $contenido = "Error";
- };
- } else {
- $contenido = "Error";
- }
- return $contenido;
- }
- sub open_file {
- my $file = shift;
- my @words;
- open( FILE,$file);
- @words = <FILE>;
- close FILE;
- return @words;
- }
- sub repes {
- my @limpio;
- foreach $test (@_) {
- push @limpio, $test unless $repe{$test}++;
- }
- return @limpio;
- }
- sub savefile {
- my ($filename,$text) = @_;
- open( SAVE, ">>" . $filename );
- print SAVE $text . "\n";
- close SAVE;
- }
- sub printear {
- cprint( "\x036" . $_[0] . "\x030" );
- }
- sub printear_logo {
- cprint( "\x037" . $_[0] . "\x030" );
- }
- sub printear_titulo {
- cprint( "\x0310" . $_[0] . "\x030" );
- }
- sub printear_rojo {
- cprint( "\x035" . $_[0] . "\x030" );
- }
- sub printear_azul {
- cprint( "\x033" . $_[0] . "\x030" );
- }
- sub sintax {
- printear("[+] Sintax : ");
- print "perl $0 <option> <value>\n";
- printear("\n[+] Options : \n\n");
- print "-google -dork <dork> -count <count> : Find emails in google\n";
- print "-bing -dork <dork> -count <count> : Find bing in google\n";
- print "-filename <filename> : Find emails in filename with URLS\n";
- print "-page <page> : Find emails in a single page\n";
- print "-savefile <savefile> : Save emails in logs\n";
- printear("\n[+] Example : ");
- print "perl dh_spider.pl -bing -dork contacto.php -count 5 -savefile emails_found.txt\n";
- copyright();
- }
- sub head {
- printear_logo("\n-- == DH Spider 0.5 == --\n\n\n");
- }
- sub copyright {
- printear_logo("\n\n-- == (C) Doddy Hackman 2016 == --\n\n");
- exit(1);
- }
- #The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement