So this evening I had to manually block 22 Tor exit nodes because they were running a denial of service attack on my server. Not my idea of a fun start of the weekend.
It turns out that the Tor project has a list of exit nodes that can reach a certain IP-address. Well, I can automate that…
#!/bin/bash
if [[ -z "$1" ]]; then
echo Usage: $0 "
exit 1
fi
hostip=$1
for i in $(wget https://check.torproject.org/cgi-bin/TorBulkExitList.py\?ip=$hostip -O- -q |\
grep -E '^[[:digit:]]+(\.[[:digit:]]+){3}$'); do
sudo iptables -A INPUT -s "$i" -j DROP
done
Leave a Reply