如何以编程方式更改 Tor 出口节点以获取新 IP? [英] How to change the Tor exit node programmatically to get a new IP?

查看:40
本文介绍了如何以编程方式更改 Tor 出口节点以获取新 IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计算机上运行着 Tor,我需要每五分钟更改一次 Tor 出口节点.例如,如果我通过某个出口节点开始使用 Tor,那么在 5 分钟后,我希望 Tor 更改为具有不同 IP 地址的出口节​​点.我该怎么做?

I have Tor running on my computer, and I need to change the Tor exit node every five minutes. For example, if I start using Tor via some exit node, then in 5 minutes I want Tor to change to an exit node with a different IP address. How can I do this?

据我所知,Tor 正在监听本地主机上的 8051 端口.

Tor, as far as I know, is listening to port 8051 on localhost.

我可以向这个端口发送什么命令来让 Tor 建立一个新的链,以便我可以获得另一个 IP 地址?

What commands can I send to this port to make Tor build a new chain, so that I can get another IP address?

推荐答案

方法一:HUP

sudo killall -HUP tor

然后检查您的 IP 是否已更改:

Then check that your IP has changed with:

curl --socks5 127.0.0.1:9050 http://checkip.amazonaws.com/

在 Ubuntu 17.10 中使用 sudo apt-get install tor 版本 1.6.0-5 进行测试.

Tested in Ubuntu 17.10 with sudo apt-get install tor version 1.6.0-5.

sudo 需要,因为进程默认是由 root 启动的.

sudo is needed since the process is started by root by default.

HUP 信号对 Tor 守护进程的作用记录在:https://gitweb.torproject.org/torspec.git/tree/control-spec.txt?id=03aaace9bd9459b0d4bf22a75012acf39d07bcec#n394 相当于通过命令端口发送一些命令.

What an HUP signal does exactly to the Tor daemon is documented at: https://gitweb.torproject.org/torspec.git/tree/control-spec.txt?id=03aaace9bd9459b0d4bf22a75012acf39d07bcec#n394 and is equivalent to sending some command through the command port.

Browser Bundle 5.0.5 不受此影响,只有像默认 9050 这样的守护进程端口,TBB 不使用它.对于该用例,请参阅:https://tor.stackexchange.com/questions/1071/how-can-a-new-circuit-happen-without-closure-all-tabs

Browser Bundle 5.0.5 is not affected by this, only daemon ports like the default 9050, which is not used by the TBB. For that use case see: https://tor.stackexchange.com/questions/1071/how-can-a-new-circuit-happen-without-closing-all-tabs

如果您正在部署大量 Tor IP如此处所述,您可以有选择地发送:

If you are deploying an army of Tor IPs as mentioned here you can selectively send:

kill -HUP $PID

方法二:控制端口

kat 提及:

(echo authenticate '""'; echo signal newnym; echo quit) | nc localhost 9051

但要在 Ubuntu 17.10 上运行,您必须先:

but for that to work on Ubuntu 17.10 you must first:

  • 通过取消注释来启用控制端口:

  • enable the control port by uncommenting:

ControlPort 9051

来自 /etc/tor/torrc

设置空密码,否则会提示515 Authentication failed: Wrong length on authentication cookie..首次运行:

Set the empty password, otherwise it gives 515 Authentication failed: Wrong length on authentication cookie.. First run:

tor --hash-password ''

这输出类似:

16:D14CC89AD7848B8C60093105E8284A2D3AB2CF3C20D95FECA0848CFAD2

现在在 /etc/tor/torrc 更新这一行:

Now on /etc/tor/torrc update the line:

HashedControlPassword 16:D14CC89AD7848B8C60093105E8284A2D3AB2CF3C20D95FECA0848CFAD2

  • 重启 Tor:

  • Restart Tor:

    sudo service tor restart
    

  • 奖励:如何检查您的 IP 是否已更改

    curl --socks5 127.0.0.1:9050 http://checkip.amazonaws.com/
    

    另见:https://askubuntu.com/questions/95910/command-for-determining-my-public-ip

    相关主题

    这篇关于如何以编程方式更改 Tor 出口节点以获取新 IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆