Ban ssh bruteforce with pf-remove.pl

From wiki.perl.lt
Jump to: navigation, search
#!/usr/bin/perl

# ban_ssh_bruteforce_with_pf-remove.pl v1.0
# copyleft algirdas @ perl.lt
#
# tested on freebsd 8.0-* (2010.05.22)
#
# use it with ban_ssh_bruteforce_with_pf.pl if you want to flush $lusers sometimes..
# f.e. add it to crontab (crontab -e):
# 12 12 * * * /usr/bin/perl /sbin/ban_ssh_bruteforce_with_pf-remove.pl >/dev/null 2>&1

use strict;

my @list = `pfctl -t bruteforce -T show`;
        foreach (@list) {
                if (/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) {
                        `/sbin/pfctl -t bruteforce -T del $1`;
                }
        }
Personal tools
Categories