可能在这里做一些非常愚蠢的事情,但是我在通过 Tor 自动进行身份验证时遇到了一些麻烦。
我正在使用带有混淆网桥的 32 位 ubuntu 12.04。
这应该是所有相关代码,但如果有其他东西对调试这个问题有用,请告诉我:
import socket
import socks
import httplib
def connectTor():
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050, True)
#9050 is the Tor proxy port
socket.socket = socks.socksocket
def newIdentity():
socks.setdefaultproxy() #Disconnect from Tor network
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 46594))
s.send("AUTHENTICATE\r\n")
response = s.recv(128)
#128 bytes of data for now, just to see how Tor responds
print response
if response.startswith("250"): #250 is the code for a positive response from Tor
s.send("SIGNAL NEWNYM\r\n") #Use a new identity
s.close()
connectTor() #Just to make sure we're still connected to Tor
每当我运行它时,我都会收到以下错误:
515 Authentication failed: Password did not match HashedControlPassword value from configuration. Maybe you tried a plain text password
我尝试使用 --hash-password 选项并将其粘贴到 AUTHENTICATE 字符串的位置,但这只会导致脚本挂起。想法?