【问题标题】:Get new identity in Tor from Ruby script从 Ruby 脚本获取 Tor 中的新身份
【发布时间】: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" 异常抛出。

【问题讨论】:

    标签: ruby tor


    【解决方案1】:

    您必须将密码放在双引号中:

    localhost.cmd('AUTHENTICATE "hi"') { |c| print c; throw "Cannot authenticate to Tor" if c != "250 OK\n" }
    

    也就是说,密码是您用tor --hash-password hi 散列的密码,但放在双引号中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 2013-06-03
      • 1970-01-01
      相关资源
      最近更新 更多