Created
November 18, 2012 05:56
-
-
Save geekgonecrazy/4103817 to your computer and use it in GitHub Desktop.
block script kiddies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Need to check this more. Could probably automate it and make it an actual script. As is don't run. Could end up banning your self | |
grep "Failed password for root from" /var/log/auth.log | cut -d " " -f 11 | sort | uniq >> banips | |
grep "Failed password for invalid user" /var/log/auth.log | cut -d " " -f 13 | sort | uniq >> banips | |
# Check banips make sure yours isn't there. Could be bad otherwise. | |
for line in $(cat banips); do echo "iptables -I INPUT -s $line -j DROP" >> iptablesblock; done; | |
chmod +x iptablesblock | |
./iptablesblock | |
iptables-save > /etc/iptables.rules | |
#add to /etc/network/if-pre-up.d/iptablesload | |
#!/bin/sh | |
#iptables-restore < /etc/iptables.rules | |
#exit 0 | |
chmod +x iptablesload | |
init 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment