麻烦蟒蛇认证的Tor
可能做一些很无聊的在这里,但我有一些麻烦,通过Tor的自动验证。
Probably doing something very silly here, but I'm having some trouble authenticating automatically through Tor.
我使用的是32位的Ubuntu 12.04与混淆的桥梁。
I'm using 32 bit ubuntu 12.04 with obfuscated bridges.
这应该是所有相关的code,但让我知道如果有别的东西,会在调试这个问题上是有用的:
This should be all the relevant code, but let me know if there's something else that would be useful in debugging this issue:
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
每当我运行此我得到以下错误:
Whenever I run this I get the following error:
515 Authentication failed: Password did not match HashedControlPassword value from configuration. Maybe you tried a plain text password
我尝试使用--hash密码选项,并粘贴,在验证字符的地方,但只是导致脚本挂起。思考?
I tried using the --hash-password option and pasting that in the place of the AUTHENTICATE string, but that just caused the script to hang. Thoughts?
这是错误意味着你设置你的torrc的HashedControlPassword选项。我建议为选项 CookieAuthentication 1
来代替,然后使用一个控制器库,而不是从头开始这样做。
That error means that you set the HashedControlPassword option in your torrc. I would suggest option for CookieAuthentication 1
instead then using a controller library rather than doing this from scratch.
你想在这里做什么(发出NEWNYM)是一种非常普遍的要求(1, 2)所以我只是增加了一个 FAQ条目它。这是一个使用干 ...
What you're trying to do here (issue a NEWNYM) is a very, very common request (1, 2) so I just added a FAQ entry for it. Here's an example using stem...
from stem import Signal
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)