MadMakz
/
Misc-Tools
Archived
1
0
Fork 0

BASH/tor-block.sh:

Fixed dublicate IP's
Made it more configuration friendly / more automatic 1st run
This commit is contained in:
MadMakz 2014-07-22 22:22:39 +02:00
parent ae5e1d1832
commit f247a08931
1 changed files with 36 additions and 33 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash
# Found at http://www.brianhare.com/wordpress/2011/03/02/block-tor-exit-nodes-using-bash-script/#codesyntax_1
# Mods (if any) by MadMakz
IPTABLES_SOURCE="INPUT"
IPTABLES_TARGET="DROP"
IPTABLES_CHAINNAME="TOR"
@ -11,6 +12,8 @@ IP_ADDRESS=$(ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}')
if ! iptables -L "$IPTABLES_CHAINNAME" -n >/dev/null 2>&1 ; then #If chain doesn't exist
iptables -N "$IPTABLES_CHAINNAME" >/dev/null 2>&1 #Create it
iptables -A "$IPTABLES_CHAINNAME" -j RETURN >/dev/null 2>&1 #Can be deleted with: iptables -D "$IPTABLES_SOURCE" -j "$IPTABLES_CHAINNAME"
iptables -I "$IPTABLES_SOURCE" -j "$IPTABLES_CHAINNAME" >/dev/null 2>&1
fi
cd $WORKING_DIR
@ -21,7 +24,7 @@ sed -i 's|^#.*$||g' temp_tor_list2
iptables -F "$IPTABLES_CHAINNAME"
CMD=$(cat temp_tor_list2 | uniq | sort)
CMD=$(cat temp_tor_list2 | sort | uniq)
for IP in $CMD; do
let COUNT=COUNT+1
@ -30,4 +33,4 @@ done
iptables -A "$IPTABLES_CHAINNAME" -j RETURN
rm -f $WORKING_DIR/temp_tor*
rm -f temp_tor*