Blacklist SSH Bruteforce Fools
If you run OpenBSD. Add this to your pf.conf
Then I wrote this little script that I run hourly via cron to update my blacklist table based on failed password attempts.
To view the current list of blacklisted ip, type:
#table of bad-guys/var/db/fsckers.txt is a plaintext file with each blacklisted ip / ip-block on a seperate line. Lines starting with # are considered comments.
table <fsckers> persist file "/var/db/fsckers.txt"
#Block Blacklisted IPs
block in on $external from <fsckers> to any
Then I wrote this little script that I run hourly via cron to update my blacklist table based on failed password attempts.
#!/bin/shI guess I also need to extend this so that it also adds it to /var/db/fsckers.txt, but that is trivial. The text file in only needed when initially loading the list.
echo "Started on: $(date)"
for each in $(grep 'Failed password' /var/log/authlog | sed 's/^.*from //;s/port.*$//' | uniq)
do
echo -n "$each\t\t--->"
pfctl -t fsckers -T add $each 2>&1
done
To view the current list of blacklisted ip, type:
pfctl -t fsckers -T showEDIT: here is my script to dump the current blacklist to fsckers.txt
#!/bin/sh
pfctl -t fsckers -T show | sed 's/^ //' > /var/db/fsckers.txt

