繁体   English   中英

如何获取正在使用的TOR条目节点的IP地址

[英]How do I get the IP address of the TOR entry node in use

我一直在寻找映射tor的方法,并查看如何分配地址,但我需要能够知道我在任何给定时间使用的入口节点的IP地址。

不确定从哪里开始,因为我不仅仅是一个熟练的程序员(python),并且倾向于根据需要学习点点滴滴。 任何指向要使用的命令的指针都会受到赞赏。

我确实认为在中间节点上运行wireshark可能是最简单的方法,但需要一台额外的机器,我没有在那一刻敲门。

实际上,这与我们的FAQ条目非常相似。 要获得当前电路的IP地址,您可以使用词干来执行以下操作...

from stem import CircStatus
from stem.control import Controller

with Controller.from_port() as controller:
  controller.authenticate()

  for circ in controller.get_circuits():
    if circ.status != CircStatus.BUILT:
      continue  # skip circuits that aren't yet usable

    entry_fingerprint = circ.path[0][0]
    entry_descriptor = controller.get_network_status(entry_fingerprint, None)

    if entry_descriptor:
      print "Circuit %s starts with %s" % (circ.id, entry_descriptor.address)
    else:
      print "Unable to determine the address belonging to circuit %s" % circ.id

这提供了像...的输出

atagar@morrigan:~/Desktop/stem$ python example.py 
Circiut 15 starts with 209.222.8.196
Circiut 7 starts with 209.222.8.196

希望这可以帮助! -Damian

txtorcon是用python编写的tor库,它将为您提供所需的所有信息。 有关指导,请参阅/ examples-files。

如果认为有必要,请在github上提交功能请求

您也可以尝试使用基于txtorcon的carml( http://carml.readthedocs.org/en/latest/ )。 carml circ --list --verbose ”将为您提供所需的信息。

为了完整性,这里是如何使用txtorcon执行上述操作:

#!/usr/bin/env/python                                                                                                                              

from twisted.internet.task import react
from twisted.internet.defer import inlineCallbacks
import txtorcon

@inlineCallbacks
def main(reactor):
    state = yield txtorcon.build_local_tor_connection(reactor)
    for circuit in state.circuits.values():
        first_relay = circuit.path[0]
        print "Circuit {} first hop: {}".format(circuit.id, first_relay.ip)

if __name__ == '__main__':
    react(main)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM