Advertisement
Guest User

Untitled

a guest
Jul 13th, 2016
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. #
  2. # You should have received a copy of the GNU General Public License
  3. # along with backbox-anonymous. If not, see <http://www.gnu.org/licenses/>.
  4.  
  5. export BLUE='\033[1;94m'
  6. export GREEN='\033[1;92m'
  7. export RED='\033[1;91m'
  8. export ENDC='\033[1;00m'
  9.  
  10. # Destinations you don't want routed through Tor
  11. NON_TOR="192.168.0.0/16 172.16.0.0/12 10.0.0.0/8"
  12.  
  13. # The GID Tor runs as
  14. TOR_GID="debian-tor"
  15.  
  16. # Tor's TransPort
  17. TRANS_PORT="9040"
  18.  
  19. case "$1" in
  20. start)
  21. # Make sure only root can run this script
  22. if [ $(id -u) -ne 0 ]; then
  23. echo "\n$RED[!] This script must be run as root$ENDC\n" >&2
  24. exit 1
  25. fi
  26.  
  27. # Check torrc config file
  28. grep -q -x 'VirtualAddrNetwork 10.192.0.0/10' /etc/tor/torrc
  29. if [ $? -ne 0 ]; then
  30. echo "\n$RED[!] Please add the following to your /etc/tor/torrc and restart service:$ENDC\n" >&2
  31. echo "$BLUE#----------------------------------------------------------------------#$ENDC"
  32. echo "VirtualAddrNetwork 10.192.0.0/10"
  33. echo "AutomapHostsOnResolve 1"
  34. echo "TransPort 9040"
  35. echo "DNSPort 53"
  36. echo "$BLUE#----------------------------------------------------------------------#$ENDC\n"
  37. exit 1
  38. fi
  39. grep -q -x 'AutomapHostsOnResolve 1' /etc/tor/torrc
  40. if [ $? -ne 0 ]; then
  41. echo "\n$RED[!] Please add the following to your /etc/tor/torrc and restart service:$ENDC\n" >&2
  42. echo "$BLUE#----------------------------------------------------------------------#$ENDC"
  43. echo "VirtualAddrNetwork 10.192.0.0/10"
  44. echo "AutomapHostsOnResolve 1"
  45. echo "TransPort 9040"
  46. echo "DNSPort 53"
  47. echo "$BLUE#----------------------------------------------------------------------#$ENDC\n"
  48. exit 1
  49. fi
  50. grep -q -x 'TransPort 9040' /etc/tor/torrc
  51. if [ $? -ne 0 ]; then
  52. echo "\n$RED[!] Please add the following to your /etc/tor/torrc and restart service:$ENDC\n" >&2
  53. echo "$BLUE#----------------------------------------------------------------------#$ENDC"
  54. echo "VirtualAddrNetwork 10.192.0.0/10"
  55. echo "AutomapHostsOnResolve 1"
  56. echo "TransPort 9040"
  57. echo "DNSPort 53"
  58. echo "$BLUE#----------------------------------------------------------------------#$ENDC\n"
  59. exit 1
  60. fi
  61. grep -q -x 'DNSPort 53' /etc/tor/torrc
  62. if [ $? -ne 0 ]; then
  63. echo "\n$RED[!] Please add the following to your /etc/tor/torrc and restart service:$ENDC\n" >&2
  64. echo "$BLUE#----------------------------------------------------------------------#$ENDC"
  65. echo "VirtualAddrNetwork 10.192.0.0/10"
  66. echo "AutomapHostsOnResolve 1"
  67. echo "TransPort 9040"
  68. echo "DNSPort 53"
  69. echo "$BLUE#----------------------------------------------------------------------#$ENDC\n"
  70. exit 1
  71. fi
  72.  
  73. echo "\n$BLUE[i] Starting anonymous mode:$ENDC\n"
  74.  
  75. if [ ! -e /var/run/tor/tor.pid ]; then
  76. echo " $RED*$ENDC Tor is not running! Quitting...\n" >&2
  77. exit 1
  78. fi
  79.  
  80. iptables -F
  81. iptables -t nat -F
  82. echo " $GREEN*$ENDC Deleted all iptables rules"
  83.  
  84. echo 'nameserver 127.0.0.1' > /etc/resolv.conf
  85. echo " $GREEN*$ENDC Modified resolv.conf to use Tor"
  86.  
  87. iptables -t nat -A OUTPUT -m owner --gid-owner $TOR_GID -j RETURN
  88. iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 53
  89. for NET in $NON_TOR 127.0.0.0/9 127.128.0.0/10; do
  90. iptables -t nat -A OUTPUT -d $NET -j RETURN
  91. done
  92. iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $TRANS_PORT
  93. iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  94. for NET in $NON_TOR 127.0.0.0/8; do
  95. iptables -A OUTPUT -d $NET -j ACCEPT
  96. done
  97. iptables -A OUTPUT -m owner --gid-owner $TOR_GID -j ACCEPT
  98. iptables -A OUTPUT -j REJECT
  99. echo "$GREEN *$ENDC Redirected all traffic throught Tor\n"
  100.  
  101. echo "$BLUE[i] Are you using Tor?$ENDC\n"
  102. echo "$GREEN *$ENDC Please refer to https://check.torproject.org\n"
  103. ;;
  104. stop)
  105. # Make sure only root can run our script
  106. if [ $(id -u) -ne 0 ]; then
  107. echo "\n$RED[!] This script must be run as root$ENDC\n" >&2
  108. exit 1
  109. fi
  110.  
  111. echo "\n$BLUE[i] Stopping anonymous mode:$ENDC\n"
  112.  
  113. echo 'nameserver 208.67.222.222' > /etc/resolv.conf
  114. echo 'nameserver 208.67.220.220' >> /etc/resolv.conf
  115. echo " $GREEN*$ENDC Modified resolv.conf to use OpenDNS"
  116.  
  117. iptables -F
  118. iptables -t nat -F
  119. echo " $GREEN*$ENDC Deleted all iptables rules\n"
  120. ;;
  121. restart)
  122. $0 stop
  123. $0 start
  124. ;;
  125. *)
  126. echo "Usage: $0 {start|stop|restart}"
  127. exit 1
  128. ;;
  129. esac
  130.  
  131. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement