Advertisement
D0cEvil

Bash - Block TOR exit nodes

Dec 27th, 2022 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | Cybersecurity | 0 0
  1. #!/bin/bash
  2.  
  3. # Block Tor Exit nodes
  4.  
  5. IPTABLES_TARGET="DROP"
  6. IPTABLES_CHAINNAME="TOR”
  7.  
  8. if ! iptables -L TOR -n >/dev/null 2>&1 ; then
  9. iptables -N TOR >/dev/null 2>&1
  10. iptables -A INPUT -p tcp -j TOR 2>&1
  11. fi
  12. cd /tmp/
  13. echo -e "\n\tGetting TOR node list from dan.me.uk\n"
  14. wget -q -O - "https://www.dan.me.uk/torlist/" -U SXTorBlocker/1.0 > /tmp/full.tor
  15. sed -i 's|^#.*$||g' /tmp/full.tor
  16. iptables -F TOR CMD=$(cat /tmp/full.tor | uniq | sort)
  17. for IP in $CMD; do
  18. let COUNT=COUNT+1
  19. iptables -A TOR -s $IP -j DROP
  20. done
  21. iptables -A TOR -j RETURN echo -e "\n\tiptables is now blocking TOR connections\n”
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement