简体   繁体   English

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

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

I've been poking around at ways to map tor, and to look at how addresses get allocated but I need to be able to know the IP address of the entry node that I'm using at any given time. 我一直在寻找映射tor的方法,并查看如何分配地址,但我需要能够知道我在任何给定时间使用的入口节点的IP地址。

Not really sure where to start as I'm not more than a journeyman programmer (python) and tend to learn bits and pieces as necessary. 不确定从哪里开始,因为我不仅仅是一个熟练的程序员(python),并且倾向于根据需要学习点点滴滴。 Any pointers to commands to use would b emuch appreciated. 任何指向要使用的命令的指针都会受到赞赏。

I did think that running wireshark on an intermediate node might be the easiest way but needs an extra machine that I don't have knocking around at the minute. 我确实认为在中间节点上运行wireshark可能是最简单的方法,但需要一台额外的机器,我没有在那一刻敲门。

Actually, this is very similar to one of our FAQ entries . 实际上,这与我们的FAQ条目非常相似。 To get the IP address of your present circuits you can do the following using stem ... 要获得当前电路的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

This provides output like... 这提供了像...的输出

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

Hope this helps! 希望这可以帮助! -Damian -Damian

txtorcon is tor library written in python which will provide you all the information you want. txtorcon是用python编写的tor库,它将为您提供所需的所有信息。 See the /examples-files for guidance. 有关指导,请参阅/ examples-files。

Please submit a feature request on github if deemed necessary 如果认为有必要,请在github上提交功能请求

You can also try carml ( http://carml.readthedocs.org/en/latest/ ) which is based on txtorcon. 您也可以尝试使用基于txtorcon的carml( http://carml.readthedocs.org/en/latest/ )。 " carml circ --list --verbose " will give you the information you desire. carml circ --list --verbose ”将为您提供所需的信息。

For completeness, here's how to do the above with txtorcon: 为了完整性,这里是如何使用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