如何知道 Tor 路由的 IP 地址? [英] How can I know the IP address of Tor route?
问题描述
我是一名在日本大学进行 Tor 研究的大学生.
I am a college student who is conducting Tor research at a Japanese university.
如何显示如图所示路由的IP地址?
How can I display the IP address of the route as shown in the picture?
我怀疑我需要从控制端口做一些操作.
I suspect I need to do some operations from the control port.
推荐答案
工作方式有点棘手.Tor 会在启动时创建不同的电路,SOCKS 请求将使用它认为合适的电路.
The way that works is a bit tricky. Tor will create different circuits when it starts up and SOCKS requests will use a circuit it finds suitable.
Tor 浏览器(由 TorButton 提供支持)具有特殊的域隔离功能,它通过使用 Tor 的 SOCKS 代理的凭据通过隔离电路代理对特定 domain:port
组合的请求.这就是如何在 Tor 浏览器中打开两个选项卡,并访问两个不同的域并为每个站点使用不同的 IP 地址(因为每个选项卡使用完全不同的电路).
The Tor browser (powered by TorButton) has special domain isolation functionality where it proxies requests for a specific domain:port
combination through an isolated circuit by using credentials with Tor's SOCKS proxy. This is how you can have two tabs open in the Tor Browser, and visit two different domains and have different IP addresses for each site (because each tab is using a completely different circuit).
要完成您想要做的事情,您需要模仿这种行为.
To accomplish what you're trying to do, you'll need to mimic this behavior.
这里有一个概念证明,可以帮助您入门.
Here is a proof of concept to get you started.
- 启动 Tor
- 连接到 Tor 的控制端口
- 开始监听 STREAM 事件
SETEVENTS STREAM
- 使用代理凭据通过 Tor 发出 SOCKS 请求(如果用户名是您要连接到的站点的域:端口组合,并且每个后续请求都将使用随机密码,则效果最佳)
- 监控与您的域目标匹配的
SENTCONNECT
事件的流事件,并从事件中提取电路 ID. - 向控制器发送
GETINFO circuit-status
命令以获取电路列表,电路路径将与上一步中的电路 ID 一起显示.
- Start Tor
- Connect to Tor's control port
- Start listening for STREAM events
SETEVENTS STREAM
- Issue a SOCKS request through Tor using proxy credentials (it will work best if the username is the domain:port combo for the site you are connecting to, and a random password you will use for each subsequent request to this domain)
- Monitor the stream events for the
SENTCONNECT
event matching your domain target and extract the circuit ID from the event. - Send a
GETINFO circuit-status
command to the controller for the list of circuits, and the circuit path will be present with the circuit ID from the previous step.
这将为您提供中继通过的节点,然后您可以获取信息以获取中继名称和地址.
This will get you the nodes you are relaying through, which you can then fetch info for to get the relay names and addresses for.
扩展上面的 PoC,这里是您可能会看到的示例输出.
Expanding on the PoC above, here is example output you could expect to see.
AUTHENTICATE "password"
250 OK
SETEVENTS STREAM
250 OK
使用代理凭据发出请求
curl --socks5-hostname localhost:9050 \
-U "torproject.org%3A:randomPasswordHere" \
https://torproject.org/donate`
代理用户名是 torproject.org:443
这是我们请求的域和端口.randomPasswordHere
是密码.
The proxy username is torproject.org:443
which is the domain and port we are requesting. randomPasswordHere
is the password.
当上述请求通过时,控制器会发送一些事件.
When the above request goes through, some events will be sent by the controller.
示例:
650 STREAM 153 NEW 0 torproject.org:443 SOURCE_ADDR=127.0.0.1:45508 PURPOSE=USER
650 STREAM 153 SENTCONNECT 38 torproject.org:443
650 STREAM 153 REMAP 38 154.35.132.71:443 SOURCE=EXIT
650 STREAM 153 SUCCEEDED 38 154.35.132.71:443
650 STREAM 153 CLOSED 38 154.35.132.71:443 REASON=DONE
我们感兴趣的事件是 SENTCONNECT
事件,其中 target
是我们请求的域端口组合.
The event we are interested in is the SENTCONNECT
event where the target
is the domain port combination we requested.
这些事件的格式是:
"650" SP "STREAM" SP StreamID SP StreamStatus SP CircuitID SP Target
[SP "REASON=" Reason [ SP "REMOTE_REASON=" Reason ]]
[SP "SOURCE=" Source] [ SP "SOURCE_ADDR=" Address ":" Port ]
[SP "PURPOSE=" Purpose]
CRLF
将该知识应用于上述数据,153
是流 ID,38
是我们感兴趣的电路 ID,torproject.org:443
是我们请求的目标.
Applying that knowledge to the above data, 153
is the stream ID, 38
is the circuit ID we are interested in, torproject.org:443
is the target we requested.
现在知道我们的请求使用的电路 ID,我们可以提取电路信息来找到请求从网络中使用的路径.
Now knowing the circuit ID our request used, we can pull circuit information to find the path the request took from the network.
GETINFO circuit-status
250+circuit-status=
38 BUILT $9E1E4F5B5F94812D02C4D18CB4086CE71CA5C614~torpidsDEhetzner1,$F0D264435B31F70FEFB322794E93211A8419F890~ANGRYRONIN,$79E169B25E4C7CE99584F6ED06F379478F23E2B8~MilesPrower BUILD_FLAGS=NEED_CAPACITY PURPOSE=GENERAL TIME_CREATED=2018-06-14T17:26:38.216992 SOCKS_USERNAME="torproject.org:443" SOCKS_PASSWORD="randomPasswordHere"
.
250 OK
您会在这里看到其他电路,但为了简单起见,我省略了它们.
You will see other circuits here, but I omitted them for simplicity.
38
是我们感兴趣的电路ID,所以可以解析电路信息发现继电器torpidsDEhetzner1
是守卫,ANGRYRONIN
是中间,MilesPrower
是出口.仔细检查 SOCKS_USERNAME
和 SOCKS_PASSWORD
字段是否存在并与请求中的字段匹配,以确保您拥有正确的电路.
38
is the circuit ID we are interested in, so you can parse the circuit information to find that the relay torpidsDEhetzner1
is the guard, ANGRYRONIN
is the middle, and MilesPrower
is the exit. Double check that the SOCKS_USERNAME
and SOCKS_PASSWORD
fields are present and match those from the request to ensure you have the right circuit.
然后您可以向控制器发出各种命令以获取有关继电器的信息.
You can then issue various commands to the controller to get info about the relays.
GETINFO ns/id/79E169B25E4C7CE99584F6ED06F379478F23E2B8
250+ns/id/79E169B25E4C7CE99584F6ED06F379478F23E2B8=
r MilesPrower eeFpsl5MfOmVhPbtBvN5R48j4rg axOufc4UeKsDqI/SrNiH31jyB1Y 2018-06-14 05:38:34 62.210.129.246 443 80
s Exit Fast Guard Running Stable V2Dir Valid
w Bandwidth=8170
.
250 OK
您可以从那里提取有关电路中继电器的 IP 地址和信息.
From there you can extract the IP address and information about the relays in the circuit.
进一步阅读:
- Tor control-spec.txt:协议实现使用 Tor 控制端口的详细信息
- Tor 浏览器设计:寻找
Tor电路和 HTTP 连接可链接性
在第 4.5 节(跨域标识符不可链接性) - torbutton 源:它是 域隔离器 和 tor-circuit-display.js
- Tor control-spec.txt: Protocol implementation details for working with the Tor control port
- Tor Browser Design: Look for
Tor circuit and HTTP connection linkability
in section 4.5 (Cross-Origin Identifier Unlinkability) - torbutton source: and it's domain-isolator and tor-circuit-display.js
像 stem (Python) 或 TorUtils (PHP)(披露:我是 PHP TorUtils 的作者)可以帮助与 Tor 控制协议进行通信.
Libraries like stem (Python) or TorUtils (PHP) (disclosure: I am the author of PHP TorUtils) can help with communicating with the Tor control protocol.
希望对您有所帮助!
这篇关于如何知道 Tor 路由的 IP 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!