Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Code


n3w7yp3's Avatar
Member
0 0

Jut saw that there were no programming forums, so I though that I'd start a thread where people could post their code….

anyways here is something that I made.

#!/usr/bin/perl

#DNS scanner v 2.0
#changes: added a timeout option
#eliminated (well, most of) the annoying system() calls
#read prefixes from a file

#written by: n3w7yp3

$timeout = shift;
if($timeout !~ /[0-9]{1,}/)
{#quit if there is no time out value
	die "Usage: $0 <timeout> <domain>\nTimeout is the delay between DNS requests.\nDomain is the domain to scan\n";
}
$host = shift;
if($host !~ /[a-z]{1,}\.[a-z]{1,}/i)
{#quit if there is no host
	die "Usage: $0 <timeout> <domain>\nTimeout is the delay between DNS requests.\nDomain is the domain to scan.\n";
}
$lookups = 0; #this will be used later to track the total number of lookups made
if(-e "prefix")
{
	if($timeout == 0)
	{#a few warnings/informative messsages that will be diplsayed to the user based on what the time out value is
		warn "WARNING: you have specified a scan with _NO_ timeout! this \*will\* be \*loud\* and \*detectable\* ! I _strongly_ recommend that you have the scan with a timeout between 5 and 10.\n";
		sleep(2);
	}
	elsif($timeout < 5)
	{
		warn "You have specified a scan with a timeout value of \*less\* than 5. I recommend a scan with a timeout between 5 and 10. that way it is less detectable.\n";
		sleep(2);
	}
	elsif($timeout >= 30)
	{
		warn "You have specified a scan with a timeout value greater than or equal to 30. This will be hard to detect, but will be slower. Please be patient.\n";
		sleep(2);
	}
	print "Doing multiple DNS lookups on $host...\n";
	$total = `wc -l prefix`; #get the number of lines in the prefix file
	open(PRE, "prefix") || die "Unable to open the prefix file (prefix)!\nQUITTING!\n"; 
	{#open it up
		system("touch host_file"); #create a file that we will stroe the DNS info in
		$file = host_file;
		system("host $host >> $file"); #do a DNS lookup on the host with no prefix
		until($total == $lookups) 
		{#keep going until the lookups are equal to the total number of lines in the prefix file
			$line = <PRE>; #grab the prefixes from the file
			chomp($line); #remove the newline
			system("host $line\.$host >> $file"); #do the DNS lookup
			sleep($timeout); #sleep for the timout value that was entered earlier
			$lookups++; #increase the lookups by 1 each time
		}
		print "SUMMARY: a total of $lookups lookups were made.\n";
		print "Assembling the lists of hosts...\n";
		print "Based on the info recived, the following hosts exist:\n\n";
		sleep(2);
		system("grep -v \"NXDOMAIN\" host_file"); #print all he resualts to the screen that dont contain the term \"NXDOMAIN\"
		print "\n\n";
		system("rm host_file"); #delete the host_file
		close PRE;
		exit; #close up and exit cleanly
	}
}
die "The prefix file, (prefix) was not found. please be sure that it is in the same dir as $0.\nQUITTING!\n";

ghost's Avatar
0 0

there's a programming forum actually.. look more closely :D


n3w7yp3's Avatar
Member
0 0

lol, I feel like an idiot. i guess thats what you get when you post at 0300……