From 5f8a3c3099b91235dac8997825891acc30eec76e Mon Sep 17 00:00:00 2001 From: MaffC Date: Sun, 17 Mar 2013 05:37:32 +0000 Subject: [PATCH] More work on aslookup --- aslookup | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/aslookup b/aslookup index 6fbb8d6..ef95736 100755 --- a/aslookup +++ b/aslookup @@ -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"; + } }