More work on aslookup

This commit is contained in:
MaffC 2013-03-17 05:37:32 +00:00
parent af7e9c4218
commit 5f8a3c3099
1 changed files with 22 additions and 4 deletions

View File

@ -11,9 +11,27 @@ my %whois_options = (
"hostname" => $default_as_server,
);
my $target = "1.1.1.1";
my $whois = Net::Whois::RIPE->new(%whois_options);
my $witerator = $whois->query('1.1.1.1');
while($witerator->isnt_exhausted()) {
my $wdata = $witerator->value()
my $witerator = $whois->query($target);
while($witerator->isnt_exhausted) {
my ($asnum,$asname,$descr,$origin,$route);
my @whoisdata = split /\n/, $witerator->value();
foreach (@whoisdata) {
$asnum = $_ if /^aut-num:/;
$asname = $_ if /^as-name:/;
$descr = $_ if /^descr:/;
$origin = $_ if /^origin:/;
$route = $_ if /^route:/;
}
if($target =~ /^AS.*/i) {
$asnum =~ s/.*:[ ]+//;
$asname =~ s/.*:[ ]+//;
print "$target advertised by $asnum - $asname\n";
} else {
$descr =~ s/.*:[ ]+//;
$origin =~ s/.*:[ ]+//;
$route =~ s/.*:[ ]+//;
print "$route advertised by $origin - $descr\n";
}
}