TAG | security
Dec/09
2
Remove an IP address ban that has been errantly blacklisted by denyhosts
No comments · Posted by admin in code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/bin/sh # denyhosts-remove.sh # # AUTHOR: Tommy Butler, email: $ echo YWNlQHRvbW15YnV0bGVyLm1lCg==|base64 -d # VERSION: 1.0 # # SUMMARY: # Use this script to Remove an IP address ban that has been errantly blacklisted # by denyhosts - the ubiquitous and unforgiving brute-force attack protection # service so often used on linux boxen. # # *Unlike the ruby equivalent somewhere out there on the net, this script # actually works. # # INSTALL: # Usage: Put this script somewhere in your $PATH, and execute it as root or # with sudo. Call it directly or with an IP address argument. Multiple IP # address arguments are not supported. You'll need to `chmod +x` it first. # # LICENSE: # GNU GPL 1.0 # Copyright 2009 Tommy Butler, All rights reserved BASE_PATH="/var/lib/denyhosts"; IP=$1 if [[ "`/usr/bin/id -u`" != "0" ]]; then echo "Run this script as root or with sudo or app can't run correctly. Aborted." exit 1; fi cd $BASE_PATH if [[ "`pwd`" != "$BASE_PATH" ]]; then echo "Couldn't cd to $BASE_PATH. Abort." exit 1; fi if [[ "$IP" == "" ]]; then echo "Enter the IP address you want to un-ban" read IP fi if [[ "$IP" == "" ]]; then echo "No IP address given. Abort." exit 1; fi /etc/init.d/denyhosts stop /usr/bin/perl -pi -e "s/^.*?$IP.*\n//g" /etc/hosts.deny * /etc/init.d/denyhosts start exit $? |

