Advertisement
Guest User

Tor Block Script

a guest
Nov 5th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement