-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparse-geo.pl
More file actions
executable file
·27 lines (23 loc) · 912 Bytes
/
parse-geo.pl
File metadata and controls
executable file
·27 lines (23 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
use Geo::IP;
#my $gi = Geo::IP->new(GEOIP_STANDARD);
# http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
# http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
# http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#my $gcity = Geo::IP->open('/usr/share/GeoIP/GeoLiteCity.dat' , GEOIP_STANDARD );
#my $gcountry = Geo::IP->open('/usr/share/GeoIP/GeoIP.dat' , GEOIP_STANDARD );
my $gasn = Geo::IP->open('/usr/share/GeoIP/GeoIPASNum.dat' , GEOIP_STANDARD );
my $recordcity,$city,$country,$ip;
while (<>) {
$ip=$_;
chomp($ip);
if ($ip =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) {
#$country = $gcountry->country_code_by_addr($ip);
$asn = $gasn -> name_by_addr($ip);
# $recordcity = $gcity->record_by_addr($ip);
#$country=$recordcity->country_code;
#$city=$recordcity->city;
printf "$ip;$asn\n";
#printf "$ip;$country\n";
}
}