Advertisement
bwall

Script for fast IP analysis

Jul 14th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.67 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use Geo::IP::PurePerl;
  3. if($#ARGV == -1)
  4. {
  5.         exit;
  6. }
  7. my $gi = Geo::IP::PurePerl->open("/usr/local/share/GeoIP/GeoIPCity.dat", GEOIP_STANDARD);
  8. my @record = $gi->get_city_record($ARGV[0]);
  9. print $ARGV[0]."\t\t#".@record[4].", ".@record[3].", ".@record[2].", ";
  10. my $gio = Geo::IP::PurePerl->open("/usr/local/share/GeoIP/GeoIPOrg.dat", GEOIP_STANDARD);
  11. my @orecord = $gio->org_by_name($ARGV[0]);
  12. print "@orecord\t";
  13. my $rdns = "";
  14. open(DIG, "dig -x ".$ARGV[0]." |");
  15. while(<DIG>)
  16. {
  17.         $line = $_;
  18.         if($line =~ /IN[[:space:]]+PTR[[:space:]]+(?<dns>.+)\./)
  19.         {
  20.                 $rdns = $rdns."\t".$1;
  21.  
  22.         }
  23. }
  24. print "$rdns \n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement