badabum
badabum

Reputation: 73

urlib2 in TAILS error 111 connection refused

I'm trying to open a simple webpage with Python using Urlib2 in a TAILS system but I am unable to make it work, with error 111, connection refused. So that is obviously because TAILS refuses all non-Tor traffic, and the solution should be opening a proxy with:

proxy = urlib2.ProxyHandler({protocol:"127.0.0.1:{}".format(PORT)})
opener = urlib2.build_opener(proxy)
opener.open("https://jojeji")

I tried lots of protocols and ports, assuming that this choice is the only problem I have. Tails has a configuration file in etc/ferm/ferm.conf. In the output part it says:

            # White-list access to Tor's SOCKSPort's
            daddr 127.0.0.1 proto tcp syn dport 9050 {
                mod owner uid-owner _apt ACCEPT;
                mod owner uid-owner proxy ACCEPT;
                mod owner uid-owner nobody ACCEPT;
            }
              daddr 127.0.0.1 proto tcp syn mod multiport 
              destination-ports (9050 9061 9062 9150) {
                mod owner uid-owner $amnesia_uid ACCEPT;
            }

There are white lists also for:

access to onionshare
access to Monkeysphere
access to CUPS
access to the accesibility daemon
access to system DNS and TOr's DNS PORT
access to Tor's TransPort
access to Tor control port filtrer
access to Tor ControlPort

So which values should a TAILS user pass to the urlib2 proxy and, is there any better way to access the internet through urlib2?

Upvotes: 1

Views: 386

Answers (1)

George Y.
George Y.

Reputation: 11799

Tails/Tor implements SOCKS5 proxy, not HTTP proxy. AFAIK, this is not directly supported by urlib2. You need to use the SocksiPy module as shown in this answer.

The socks proxy is 127.0.0.1 and the port is 9050.

Your other option is to use pycurl or even command-line curl (with --socks5-hostname=127.0.0.1:9050)

Upvotes: 1

Related Questions