Guest User

Untitled

a guest
Apr 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.53 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/GeoIP.dat', GEOIP_INDEX_CACHE) or die $!;
  13.  
  14. map {
  15.     /\(host=(\d+.\d+.\d+.\d+)/;
  16.     my $ip = $1;
  17.  
  18.     next if $region->{$ip};
  19.  
  20.     print $ip . "\n";
  21.     my $record = $gi->record_by_addr($ip);
  22.  
  23.     $region->{$ip}->{continent} = $record->continent_code;
  24.     $region->{$ip}->{country} = $record->country_name;
  25.  
  26. } grep /connection established/, <>;
  27.  
  28. print Dumper($region);
Add Comment
Please, Sign In to add comment