-
-
Save JamesBondsky/223607f5b09d144563cabe2f508ec2a0 to your computer and use it in GitHub Desktop.
iptables: Блокировка входящего TOR-трафика
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
#!/bin/bash | |
# Block Tor Exit nodes | |
IPTABLES_TARGET="DROP" | |
IPTABLES_CHAINNAME="TOR" | |
EXTERNAL_IP="xx.xx.xx.xx" | |
if ! iptables -L TOR -n >/dev/null 2>&1 ; then | |
/sbin/iptables -N TOR >/dev/null 2>&1 | |
/sbin/iptables -A INPUT -p tcp -j TOR 2>&1 | |
fi | |
/sbin/iptables -F TOR | |
/usr/bin/curl "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=${EXTERNAL_IP}" 2> /dev/null | /bin/grep -v '#' | /usr/bin/sort | /usr/bin/uniq | | |
while read IP | |
do | |
let COUNT=COUNT+1 | |
/sbin/iptables -A TOR -s $IP -j DROP | |
done | |
/sbin/iptables -A TOR -j RETURN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment