Skip to content

Instantly share code, notes, and snippets.

@random-robbie
Last active December 9, 2016 11:47
Show Gist options
  • Save random-robbie/0fa4221813d860280e1f901b0cbedb57 to your computer and use it in GitHub Desktop.
Save random-robbie/0fa4221813d860280e1f901b0cbedb57 to your computer and use it in GitHub Desktop.
torblock via iptables
# # # # # # # # # # # # #
#Authors: Blake Self & #
# Shawn Burrel #
# #
# Modified by LukeBob #
# # # # # # # # # # # # #
#!/bin/bash
#Block tor exit nodes
IPTABLES_TARGET="DROP"
IPTABLES_CHAINNAME="TOR"
if ! iptables -L TOR -n >/dev/null 2>&1 ; then
iptables -N TOR >/dev/null 2>&1
iptables -A INPUT -p tcp -j TOR 2>&1
fi
cd /tmp/
echo -e "\n\tGetting Tor node list from dan.me.uk\n"
wget -q -O - https://www.dan.me.uk/torlist/ -U SXTorBlocker/1.0 > /tmp/full.tor
iptables -F TOR
CMD=$(cat /tmp/full.tor | uniq | sort)
for IP in $CMD; do
let COUNT=COUNT+1
iptables -A TOR -s $IP -j DROP
done
iptables -A TOR -j RETURN
echo -e "\n\tIptables now blocking TOR connections !\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment