Skip to content

Instantly share code, notes, and snippets.

@geekgonecrazy
Created November 18, 2012 05:56
Show Gist options
  • Save geekgonecrazy/4103817 to your computer and use it in GitHub Desktop.
Save geekgonecrazy/4103817 to your computer and use it in GitHub Desktop.
block script kiddies
## 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