Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- NON_TOR=`ifconfig | grep "inet:" | awk -F: '{print $2}' | awk '{print $1}' | xargs echo`
- ID=`id -u debian-tor`
- TCP="9040"
- DNS="53"
- TORRC="/etc/tor/torrc"
- function stop {
- iptables -F
- iptables -t nat -F
- iptables -t nat -XT
- iptables -P FORWARD ACCEPT
- iptables -P OUTPUT ACCEPT
- iptables -P INPUT ACCEPT
- cp /etc/resolv.conf.orig /etc/resolv.conf
- echo "Trasparent Proxy Stop......"
- }
- function torrc_config {
- echo "Torrc configure for Trasparent Proxy..."
- cat << EOF >> $TORRC
- VirtualAddrNetwork 10.192.0.0/10
- echo "AutomapHostsOnResolve 1
- TransPort 9040
- DNSPort 53
- EOF
- echo "restarting tor..."
- /etc/init.d/tor restart
- }
- function trasparent_proxy {
- cp /etc/resolv.conf /etc/resolv.conf.orig
- echo "nameserver 127.0.0.1" > /etc/resolv.conf
- iptables -t nat -F
- iptables -t nat -A OUTPUT -p tcp -d 10.192.0.0/10 -j REDIRECT --to-ports $TCP
- iptables -t nat -A OUTPUT -m owner --uid-owner $ID -j RETURN
- iptables -t nat -A OUTPUT -p udp --dport $DNS -j REDIRECT --to-ports $DNS
- for NET in $NON_TOR; do
- iptables -t nat -A OUTPUT -d $NET -j RETURN
- done
- iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $TCP
- iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- for NET in $NON_TOR; do
- iptables -A OUTPUT -d $NET -j ACCEPT
- done
- iptables -A OUTPUT -m owner --uid-owner $ID -j ACCEPT
- iptables -A OUTPUT -j REJECT --reject-with icmp-net-prohibited
- echo "Tor Trasparent Proxy start....."
- }
- function help {
- cat << EOF
- Tor Trasparent Proxy
- Usage: sudo ./file <option>
- Option:
- -i --install
- -s --stop
- -r --run
- -h --help
- EOF
- }
- args=`getopt -l help,run,stop,install :hrsi $*`
- for i in $args; do
- case $i in
- -h|--help)
- help
- ;;
- -r|--run)
- trasparent_proxy
- ;;
- -s|--stop)
- stop
- ;;
- -i|--install)
- torrc_config
- ;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement