如何以编程方式更改 Tor 出口节点以获得新 IP?
我的计算机上运行着 Tor,我需要每五分钟更改一次 Tor 出口节点。 例如,如果我开始通过某个出口节点使用 Tor,那么我希望 Tor 在 5 分钟内更改为具有不同 IP 地址的出口节点。我该怎么做?
据我所知,Tor 正在监听本地主机上的 8051 端口。
我可以向此端口发送哪些命令来让 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, as far as I know, is listening to port 8051 on localhost.
What commands can I send to this port to make Tor build a new chain, so that I can get another IP address?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
方法 1:HUP
然后检查您的 IP 是否已更改 with:
在 Ubuntu 17.10 中使用
sudo apt-get install to
版本 1.6.0-5 进行测试。需要
sudo
因为该进程默认由 root 启动。HUP 信号对 Tor 守护进程的确切作用记录在: https://gitweb.torproject.org/torspec.git/tree/control-spec.txt?id=03aaace9bd9459b0d4bf22a75012acf39d07bcec#n394 相当于通过命令端口发送一些命令。
Browser Bundle 5.0.5 不受此影响,只有守护进程端口(例如默认 9050),TBB 不使用该端口。对于该用例,请参阅:https:// tor.stackexchange.com/questions/1071/how-can-a-new-circle-happen-without-looking-all-tabs
如果您正在部署大量 Tor IP 正如这里提到的,您可以有选择地发送:
我们可以按端口选择 PID,如下所示:https://unix.stackexchange.com/questions/106561/finding-the-pid-of-the-process- using-a-specific-port 例如更改在端口 9050 侦听的 Tor 的 IP:
方法 2:控制端口
由 kat:
但要在 Ubuntu 17.10 上运行,您必须首先:
通过取消注释来启用控制端口:
<前><代码>控制端口 9051
来自
/etc/tor/torrc
设置空密码,否则会给出
515 身份验证失败:身份验证 cookie 长度错误。
。第一次运行:输出如下:
<前><代码>16:D14CC89AD7848B8C60093105E8284A2D3AB2CF3C20D95FECA0848CFAD2
现在在
/etc/tor/torrc
上更新行:<前><代码>HashedControlPassword 16:D14CC89AD7848B8C60093105E8284A2D3AB2CF3C20D95FECA0848CFAD2
重新启动 Tor:
相关主题
Method 1: HUP
Then check that your IP has changed with:
Tested in Ubuntu 17.10 with
sudo apt-get install tor
version 1.6.0-5.sudo
is needed since the process is started by root by default.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 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
If you are deploying an army of Tor IPs as mentioned here you can selectively send:
We can select the PID by port as per: https://unix.stackexchange.com/questions/106561/finding-the-pid-of-the-process-using-a-specific-port E.g. to change IP of the Tor listening in at port 9050:
Method 2: control port
Mentioned by kat:
but for that to work on Ubuntu 17.10 you must first:
enable the control port by uncommenting:
from
/etc/tor/torrc
Set the empty password, otherwise it gives
515 Authentication failed: Wrong length on authentication cookie.
. First run:This outputs something like:
Now on
/etc/tor/torrc
update the line:Restart Tor:
Related threads
这个问题似乎经常出现(1,2),所以我刚刚添加了 常见问题解答条目 。如前所述,您可以通过 NEWNYM 信号来完成此操作。这是通过 stem 执行此操作的示例...
This question seems to come up pretty frequently (1, 2) so I just added a FAQ entry for it. As mentioned earlier you can do this via a NEWNYM signal. Here's an example for doing it via stem...
是的,那就是 1(我的意思是 =true =)))tor 每 10 分钟就会更改一次 ip
但!如果我重新启动tor - 即使在这10分钟的间隔内我也会得到一个新的IP。
所以我正在考虑让tor手动发送这个“change_ip”请求。
请参阅此代码(根据 http://en.linuxreviews.org/HOWTO_use_the_Internet_anonymously_using_Tor_and_Privoxy 编写)
并按照 [ https://tor-svn.freehaven.net/svn/ torctl/trunk/doc/howto.txt] 我可以编写一个控制器来动态更改 Tor 的配置。
默认情况下它没有启用(我的意思是这种能力),但我可以让tor客户端监听某个端口以使用torrc接受命令...如果我没有记错的话...再次=)
!!! torrc 在我的电脑上到底在哪里?
在 C:\Users\geekman\AppData\Roaming\Tor 我可以找到它
我有远景。
yeah, that's 1 (i mean =true =))) that tor does change ip every 10 minutes
but! if i restart tor - i'll get a new ip even in this 10minutes interval.
so i was thinking about making tor to send this "change_ip" request manually.
see this code (written according to http://en.linuxreviews.org/HOWTO_use_the_Internet_anonymously_using_Tor_and_Privoxy)
and accornig to [https://tor-svn.freehaven.net/svn/torctl/trunk/doc/howto.txt] i can write a controler that will change tor's conf on the fly.
by default it is not enebled (i mean this ability), but i can make tor client listen to some port for accepting commands using torrc...if i'm not mistaken...again=)
!!! where the hell torrc is on my pc?
In C:\Users\geekman\AppData\Roaming\Tor i could,n fing it
i got vista.
我为自己制作了一个 shell 脚本,也可以让您远程执行此操作(如果 Tor 服务器在另一台机器上运行)。
它可以在这里找到:https://gist.github.com/kirelagin/9667900。
I've made a shell script for myself that also lets you do this remotely (if Tor server is running on another machine).
It's available here: https://gist.github.com/kirelagin/9667900.
您只需在 bash 脚本中输入或插入:
You can simply type or insert in your bash script:
如果您无权访问控制端口,您可以使用不同的电路来更改您的 IP*。这可以通过指定不同的socks用户名来完成:
如果您想在某个时候重复使用特定的IP,您可以使用之前使用的相同用户名再次获取该IP。
* 每次退出节点都是随机的,并且有轻微的机会你会连续两次获得相同的IP。
如果我错了,请纠正我,我不是 Tor 专家,但这对我有用。
If you don't have access to the control port, you could use a different circuit which changes your IP*. This can be done by specifying a different socks username:
If you want to reuse a specific IP at some point you can use the same username you used before to get that IP again.
* The exit node will be random every time and there is a slight chance you'll get the same IP twice in a row.
Correct me if I'm wrong, I'm not a Tor expert, but this works for me.
您无法控制 Tor 网络中的路由(如果有的话,有人可能会滥用此功能)。但 Tor 已经大约每 10 分钟切换一次路线(至少根据德语维基百科文章< /a>)。
You have no control over the routing in the tor network (if you had, someone could abuse this feature). But tor already switches the route roughly every 10 minutes (at least according to the German Wikipedia article).
Advtor 使您可以访问几乎所有通过 Tor 网络运行的高级设置。
Advtor gives you access over almost all advanced settings which works over tor network.
我在这里做了一些不同的事情...我编写了一个可以与 linux shell 通信的 PHP 程序。该程序将定期重新启动 tor。
所以当tor重新启动时,它会获得一个新的IP....是的......!!
您还可以编写 shell 脚本来执行此操作。
我现在正在寻找一个 Windows 选项来执行此操作。问题是..在Windows中Tor是一个无法重新启动的服务。
I have done something different here... i wrote a PHP program that can communicate with linux shell. The program would restart tor in regular intervals.
So when tor is restarted it gets a new IP.... Yeah.....!!
You can also write a shell script to do this.
I am now in search of a windows option to do this. The problem is .. in windows Tor is a service which cannot be restarted.
我编写了一个库来使用 PHP 控制 Tor。它可以与 Composer 一起安装,并允许更改退出节点。
当然它是免费软件:http://dunglas。 fr/2013/02/php-torcontrol-a-library-to-control-tor/
I've wrote a library to control Tor with PHP. It is installable with Composer and allows to change the exit node.
Of course it's free software: http://dunglas.fr/2013/02/php-torcontrol-a-library-to-control-tor/