« Windows Vista Security Guide | Main

Processing Whois Output Automatically With Perl

I found myself in the situation where I had to whois a large number of IP addresses and play with the output in Excel.

Thanks to Ben Schmitz's Net::Whois::IP Perl extension for looking up the whois information for IP addresses and some Google searching to locate some decent usage example (found in the whois.snortalog file in Jérémy Chartier's SnortAlog), I could put together the following lame script:

#!/usr/bin/perl
require "whois.snortalog";
use Net::Whois::IP;
$k = $ARGV[0];
whois();
print $ARGV[0] . "\t" . $inetnum . "\t" . $netname . "\n";

It expects an IP address in argument and outputs it along with its NetRange and NetName separated by tabulations.

Please post a comment if you improve it (e.g., adding error handling, etc.).

About

This page contains a single entry from the blog posted on May 14, 2007 7:01 PM.

The previous post in this blog was Windows Vista Security Guide.

Many more can be found on the main index page or by looking through the archives.