Guest User

Untitled

a guest
Apr 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.55 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use Geo::IP;
  7. use Data::Dumper;
  8.  
  9. my @rawlines;
  10. my $region;
  11.  
  12. my $gi = Geo::IP->open('/home/kovensky/GeoIPCountryWhois.csv', GEOIP_INDEX_CACHE) or die $!;
  13.  
  14. map {
  15.   my $ip = $_ =~ m/\(host=(\d+.\d+.\d+.\d+)/;
  16.  
  17.   if ( defined($region->{$ip}) ) {
  18.     next;
  19.   }
  20.  
  21.   print $ip . "\n";
  22.   my $record = $gi->record_by_addr($ip);
  23.  
  24.   $region->{$ip}->{continent} = $record->continent_code;
  25.   $region->{$ip}->{country} = $record->country_name;
  26.  
  27. } grep /connection established/, <>;
  28.  
  29. print Dumper($region);
Add Comment
Please, Sign In to add comment