【发布时间】:2014-12-07 22:18:56
【问题描述】:
require 'net/telnet'
localhost = Net::Telnet::new("Host" => "localhost", "Port" => "9151", "Timeout" => 10, "Prompt" => /250 OK\n/)
localhost.cmd('AUTHENTICATE hi') { |c| print c; throw "Cannot authenticate to Tor" if c != "250 OK\n" }
localhost.cmd('signal NEWNYM') { |c| print c; throw "Cannot switch Tor to new route" if c != "250 OK\n" }
localhost.close
我试图在使用 ruby 脚本运行 Tor 时获得新的身份,代码取自这个答案:https://stackoverflow.com/a/6882744/3192470。
我的端口是9151,因为我使用Tor-Bundle。
为了获得密码哈希,我在终端中写了tor --hash-password hi,它返回了16:970D11D59DCAC06E6075BED460511460C1EFD9CECDBB3C96A59298422A。
我的 torrc 文件中相应地有这一行 HashedControlPassword 16:970D11D59DCAC06E6075BED460511460C1EFD9CECDBB3C96A59298422A。
当我运行我的 Ruby 脚本时,我得到了uncaught throw "Cannot authenticate to Tor" 异常抛出。
【问题讨论】: