3

Privoxy is for anonymising http/https traffic and tor for socks, so here is my question; can I channel all traffic (no matter what ftp,socks,http) to privoxy and then have it to channel it to tor? Is it going to be anonymous setup? I have Linux privoxy listen at 8118 and channel to 9050 (tor port, and all 127.0.0.1). Also how do I channel all system traffic through this setup if it's anonymous. + why when I connect through proxychains (configured to use http 8118 port as a proxy with privoxy configured as I said earlier) it doesn't hide ads, while when I connect only through privoxy it hide them well. Also I heard that system timezone and actual time can reveal identity, and for example in tails os it's changing every time you launch tor browser, has anyone wrote such shell script ?

1 Answer 1

2

Yes, channeling all your traffic through Tor is very much possible. It can be done using transparent proxy. For details, see this page on Tor Documentation: https://trac.torproject.org/projects/tor/wiki/doc/TransparentProxy

To implement the transparent proxy, all you have to do is to modify your iptables.

I wrote a shell script to automate this process a long time back. It should still work just fine. Just modify the tor user's uid and tor's port and it should be up and running. What this script does is that it toggles your tor proxy. Here is the script:

#!/bin/bash
#This script switches on/off the tranparent tor proxy

###############################
#### Function Definitions #####
###############################

#This function resets iptables to their default state
reset_iptables () {
  IPTABLES="$(which iptables)"

  # RESET DEFAULT POLICIES
  $IPTABLES -P INPUT ACCEPT
  $IPTABLES -P FORWARD ACCEPT
  $IPTABLES -P OUTPUT ACCEPT
  $IPTABLES -t nat -P PREROUTING ACCEPT
  $IPTABLES -t nat -P POSTROUTING ACCEPT
  $IPTABLES -t nat -P OUTPUT ACCEPT
  $IPTABLES -t mangle -P PREROUTING ACCEPT
  $IPTABLES -t mangle -P OUTPUT ACCEPT

  # FLUSH ALL RULES, ERASE NON-DEFAULT CHAINS
  $IPTABLES -F
  $IPTABLES -X
  $IPTABLES -t nat -F
  $IPTABLES -t nat -X
  $IPTABLES -t mangle -F
  $IPTABLES -t mangle -X
}

#This function modifies iptables so that they are compatible with the transparent tor proxy
tor_iptables () {
  ### set variables
  #destinations you don't want routed through Tor
  _non_tor="192.168.1.0/24 192.168.0.0/24"

  #the UID that Tor runs as (varies from system to system)
  _tor_uid="120"

  #Tor's TransPort
  _trans_port="9040"

  ### flush iptables
  iptables -F
  iptables -t nat -F

  ### set iptables *nat
  iptables -t nat -A OUTPUT -m owner --uid-owner $_tor_uid -j RETURN
  iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 53

  #allow clearnet access for hosts in $_non_tor
  for _clearnet in $_non_tor 127.0.0.0/9 127.128.0.0/10; do
     iptables -t nat -A OUTPUT -d $_clearnet -j RETURN
  done

  #redirect all other output to Tor's TransPort
  iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $_trans_port

  ### set iptables *filter
  iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

  #allow clearnet access for hosts in $_non_tor
  for _clearnet in $_non_tor 127.0.0.0/8; do
     iptables -A OUTPUT -d $_clearnet -j ACCEPT
  done

  #allow only Tor output
  iptables -A OUTPUT -m owner --uid-owner $_tor_uid -j ACCEPT
  iptables -A OUTPUT -j REJECT
}


############################
#### Main Script Starts ####
############################

if [ "$(cat /etc/resolv.conf | grep 127.0.1.1)" ]
then
  echo "Tor transparent proxy is NOT running. It will be now switched ON."
  sed -i 's/127\.0\.1\.1/127\.0\.0\.1/g' /etc/resolv.conf # Replacing 127.0.1.1 with 127.0.0.1
  tor_iptables 
else
  echo "Tor transparent proxy is ALREADY running. Let us switch it OFF."
  sed -i 's/127\.0\.0\.1/127\.0\.1\.1/g' /etc/resolv.conf # Replacing 127.0.0.1 with 127.0.1.1
  reset_iptables
fi
2
  • But won't privoxy do the job ??
    – I I
    Commented May 4, 2015 at 9:34
  • 1
    Yes, I guess it should. But using transparent proxy is also one of the ways. And this script I use is pretty convenient. Just switch on and off at my wish.
    – shivams
    Commented May 4, 2015 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .