urlib2 in TAILS错误111连接被拒绝

2024-05-28 23:58:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用python在TAILS系统中使用Urlib2打开一个简单的网页,但我无法使它工作,错误111,连接被拒绝。这显然是因为TAILS拒绝所有非Tor流量,解决方案应该是打开一个代理:

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

我尝试了很多协议和端口,但我觉得这个选择是我唯一的问题。Tails在etc/ferm/ferm.conf中有一个配置文件。在输出部分,它说:

            # 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;
            }

还有白名单:

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

那么,TAILS用户应该传递给urlib2代理的值是多少,有没有更好的方法通过urlib2访问互联网呢?你知道吗


Tags: tomod代理uidaccessportopenertor
1条回答
网友
1楼 · 发布于 2024-05-28 23:58:35

Tails/Tor实现SOCKS5代理,而不是HTTP代理。另外,urlib2不直接支持这一点。您需要使用SocksiPy模块as shown in this answer。你知道吗

socks代理是127.0.0.1,端口是9050。你知道吗

另一个选项是to use pycurl甚至是命令行curl(socks5 hostname=127.0.0.1:9050)

相关问题 更多 >

    热门问题