SHARE
TWEET

Tor Block Script

a guest Nov 5th, 2015 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Simple iptables rules to block tor connections on your server
  3. # Created by Bruno P. Gonçalves
  4.  
  5. # Configure
  6. _pub_if="eth0"
  7. IPTABLES=/sbin/iptables
  8.  
  9. # Get exit ipts
  10. wget -q -O - "https://check.torproject.org/exit-addresses" > /tmp/full.tor
  11. grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /tmp/full.tor > /tmp/ips.tor
  12.  
  13. # Create chain and add ips
  14. $IPTABLES -N torlist
  15. $IPTABLES -I INPUT -s 0.0.0.0/0 -j torlist
  16. while read ipaddr
  17. do
  18.         $IPTABLES -I torlist -s $ipaddr -j DROP
  19. done </tmp/ips.tor | sort | uniq
  20.  
  21. $IPTABLES -A torlist -j RETURN
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top