#!/usr/bin/perl # Needed packages use strict "vars"; use Getopt::Std; use Term::ANSIColor; # command line options # my $opt_string = "vdh"; # getopts( "$opt_string", \my %opt ) or usage() and exit(1); # if ( $opt{'h'} ) { # usage(); # exit 0; # } ##################################################### # Main part my $FILE="South_America-Top525"; open(LOG, "$FILE") or die "Error opening $FILE $!\n"; while ( my $line = ) { # print color 'green'; print $line; # print color 'reset'; findIP($line); } close(LOG); exit 0; ##################################################### # subroutines sub findIP { my $IP; open(NSLOOKUP, "nslookup $_[0] | ") or die "Error doing NSLOOKUP $!\n"; while (my $targetline = ) { if ($targetline =~/Address: (.*)(.*)(.*)(.*)$/) { $IP= "$1$2$3$4"; print "$IP,"; findlocation($IP); } } print "----------------------------------------------------------------------\n"; } sub findlocation { open(GEO,"wget -q -O - http://www.geoiptool.com/en/?IP=$_[0] | ") or die "Error creating file $!\n"; while ( my $targetline = ) { if ($targetline =~ /^.*Country<\/strong>: (.*)
/) { # print "IP GEO-LOCATION is: "; # print color 'bold red'; print $1; # print color 'reset'; print "\n"; } } return 0 ; }