#!/usr/bin/perl -w use strict; my $arin="/usr/bin/whois -h whois.arin.net"; my $ripe="/usr/bin/whois -h whois.ripe.net"; my $apnic="/usr/bin/whois -h whois.apnic.net"; my $krnic="/usr/bin/whois -h whois.krnic.net"; my $email; my $domain; my $result; my $ips = "203.197.64.42"; whois($ips); sub whois{ my $ip = $_[0]; $result = `$arin $ip`; if ($result =~ m/European Regional Internet Registry/){ $result = `$ripe $ip`; if (match()){ } #close if match } #close if result elsif ($result =~ m/Asia Pacific Network Information Center/){ $result = `$apnic $ip`; if ($result =~ m/hostmaster\@apnic.net/){ last; }#end if if ($result =~ m/Allocated to KRNIC Member/){ $result = `$krnic $ip`; } #end KRNIC match if (match()){ } #end if match } #end elsif elsif (handles($arin)){ if (match()) { } #end if match } #end elsif elsif (($email, $domain) = $result =~ m/([-.\w]+)(\@[-.\w]+)/) { print "The 1st email address is: $email$domain\n"; print "Email will also be sent to: abuse$domain\n"; } #end elsif else { print "Can not perform a whois query for $ip\n;" } #end else } #close whois sub ############### # Subroutines # ############### # whois: Obtain an email address from a whois query # sub match { ($email, $domain) = $result =~ m/([-.\w]+)(\@[-.\w]+)/; print "The 1st email address is: $email$domain\n"; print "Email will also be sent to: abuse$domain\n"; } #end sub match # handles: Obtain the handles from a whois query # sub handles { my $registry = $_[0]; $result =~ m/xxx/; my @handle = $result =~ m/\((.*?)\)/g; $result = `$registry $handle[1]`; } #end handles