#!/usr/bin/perl #DNS resolver by Ph03n1X use Net::DNS; use strict; use Switch; use warnings; use POSIX; use Getopt::Long; my $MAXCHILD = 50; my $LOGFILE = './logs/dns6.log'; sub usage { print " Domain6 Enumerator Usage : [--help|-h] - This help [--domain|-d] - Target domain [--file|-f] - Target domain list in file \n"; } sub resolve { my $rr; my($thost)=@_; open(LOGDNS,">>$LOGFILE") or die("Can not open file for writing"); my $r = Net::DNS::Resolver->new( debug => 0, udp_timeout => 3, tcp_timeout => 3, ); my $q = $r->query($thost,'AAAA'); if($q){ foreach $rr (grep { $_->type eq 'AAAA' } $q->answer ) { print "[$thost] " . $rr->address . "\n"; print LOGDNS "[$thost] " . $rr->address . "\n"; } } close(LOGDNS); } MAIN: { my @DOMAINS=(); my $thost; my $count=0; if(!$ARGV[0]){ usage(); exit; } my($help,$domain,$file,$type); GetOptions( 'help' => \$help, 'domain=s' => \$domain, 'file=s' => \$file, ) or die "Invalid options!! Try --help for details.\n"; if($help){ usage(); exit; } if($domain && $file){ print "ERROR! Can not use [--domain|-d] with [--file|-f]\n"; exit; } if($domain){ resolve($domain); } if($file){ open(F_DNS,"<$file") or die("Can not open file for reading"); chop(@DOMAINS=); foreach $thost (@DOMAINS){ switch(fork()){ case (0) { resolve($thost);_exit(0); } case (-1) { print "Can not fork!\n";_exit(-1); } else { if($count>$MAXCHILD-2){ wait();$count--; } #End if MAXCHILD } #End else } #End switch $count++; } #End foreach close(F_DNS); } #End if $file } #End MAIN