#!/usr/bin/perl # by Dean Peters # http://healyourchurchwebsite.com/ # # A fast little PERL script to bulk identify IPs by countries # who don't have IP abuse administrators who care, and generate # a bash script to insert the entries into my apf firewall # deny_hosts.rules file. # use IP::Country::Fast; use Geography::Countries; my $reg = IP::Country::Fast->new(); print "#/bin/sh\n"; print "# -- append firewall --\n"; while() { chomp; my $ip = $_; my $ip_cntry_abr = $reg->inet_atocc($ip); my $ip_cntry_nam = country $ip_cntry_abr; next if ($ip_cntry_abr =~ m/US|CA|GB|AU|NZ/i); print "/etc/apf/apf -d $ip {mad spammer from $ip_cntry_nam}\n"; } print "# -- restart firewall --\n"; print "/etc/apf/apf -r\n"; __DATA__ 121.1.29.246 121.15.200.148 193.238.213.70 196.20.7.74 210.22.83.146 217.30.244.226 222.124.200.212