#!/usr/local/bin/perl # mylookup.cgi by David Efflandt tech@de-srv.com # Especially useful for looking up spam/porno sites that try to # disguise their IP as a string of numbers with no dots. use Socket; use CGI qw/:standard/; print header,start_html('Resolve IP/Host'),h1('Resolve IP/Host'),hr; if (param) { my $lookup = param('lookup'); print "Lookup: ",b($lookup),p; $ip = join(".",unpack("C4",scalar gethostbyname($lookup))); print "IP: ",b($ip),p; $rhost = gethostbyaddr(inet_aton($ip), AF_INET); print "Simple Reverse lookup: ",b($rhost).hr; print "Possibly more details using a longer list",p; ($name,$alias,$adrtype,$length,@address) = gethostbyaddr(inet_aton($ip),AF_INET); print "Resolved hostname: ",($name) ? b($name) : "(none)",p; print "alias: ",($alias) ? b($alias) : "{none)",p, "address: "; foreach (@address) { @ip = unpack("C4",$_); print b(join(".",@ip))," "; } # Not sure what these are, but uncomment following to print #print p,"length: $length",p,"type: $adrtype",p; } else { print p,"This script demonstrates different methods of doing ", "forward and reverse lookup of hostnames or IP addresses. ", "Note that reverse lookup does not necessarily return a name ", "and may not reveal other name(s) that resolve to that IP. ", "It can resolve an IP and might reveal the hostname of websites ", "that try to hide behind an all digit domain",p; } print hr,start_form,"Enter name or IP to resolve: ", textfield('lookup'),' ',submit(undef,'Resolve'),br, "Works for 10 digit numbers used to hide real domain", end_form,end_html;