Pregunta

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.

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. 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.

¿Fue útil?

Solución

Actually, this is very similar to one of our FAQ entries. To get the IP address of your present circuits you can do the following using stem...

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

Otros consejos

txtorcon is tor library written in python which will provide you all the information you want. See the /examples-files for guidance.

Please submit a feature request on github if deemed necessary

You can also try carml (http://carml.readthedocs.org/en/latest/) which is based on txtorcon. "carml circ --list --verbose" will give you the information you desire.

For completeness, here's how to do the above with 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)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top