Script Bloqueio TOR via Iptables

————————————————————————————————————————————————————

#!/bin/bash
#——————————————————————————
#
# File: blockproxyanon.sh
# Descricao : Bloqueio Proxy Anonymous via IPS HOSTS
# Modificado : Marlo Luiz Binsfeld
# Original : http://www.brianhare.com/wordpress/2011/03/02/block-tor-exit-nodes-using-bash-script/#codesyntax_1
#
#——————————————————————————

IPTABLES_TARGET=”DROP”
IPTABLES_CHAINNAME=”TOR”

WORKING_DIR=”/etc/blockproxyanon/”

# get IP address of eth0 network interface
IP_ADDRESS=$(curl -s checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’)

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
fi

cd $WORKING_DIR

# Fazer manualmente
#rm -rf listed_ip_7.zip
#rm -rf ipsblocklist
#wget –progress=bar – http://www.stopforumspam.com/downloads/listed_ip_7.zip
#unzip -o listed_ip_7.zip

wget -q -O – “https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=80” -U NoSuchBrowser/1.0 > ipsblocklisttor
wget -q -O – “https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=9998” -U NoSuchBrowser/1.0 >> ipsblocklisttor
sed -i ‘s|^#.*$||g’ ipsblocklisttor
sed ‘/^$/d’ ipsblocklisttor > /tmp/ipsblocklist
cat /tmp/ipsblocklist | grep -v “#” > ipsblocklist

iptables -F “$IPTABLES_CHAINNAME”

CMD=$(cat listed_ip_7.txt ipsblocklist | uniq | sort)

for IP in $CMD; do
let COUNT=COUNT+1
iptables -A “$IPTABLES_CHAINNAME” -s $IP -j $IPTABLES_TARGET
done

iptables -A “$IPTABLES_CHAINNAME” -j RETURN
————————————————————————————————————————————————————
Créditos : http://www.brianhare.com/wordpress/2011/03/02/block-tor-exit-nodes-using-bash-script/#codesyntax_1
Download : blockproxyanon.sh

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *