Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the Tor exit node IP address over the control port?

Tags:

exit

ip

tor

I want to monitor the status of running Tor instances.

I am already able to get information via a TCP connection to the control ports. E.g. "GETINFO stream-status" returns data, but I am not able to determine the IP address of the currently chosen exit node.

It would be possible to simply request something like whatismyip.org, but that is too slow and does not scale well.

So what is the best way to get the exit node IP address of a Tor connection?

like image 401
pintpint Avatar asked Mar 19 '12 20:03

pintpint


People also ask

How do I find Tor exit nodes?

Tor exit nodes can be detected in a web application's log of connections that have been made to the server, if they include the public source IP address of the transaction initiator.

What is Tor exit node IP?

Tor Exit Nodes are the gateways where encrypted Tor traffic hits the Internet. This means an exit node can be abused to monitor Tor traffic (after it leaves the onion network). It is in the design of the Tor network that locating the source of that traffic through the network should be difficult to determine.

Does Tor exit node know your IP?

The exit node is the point in which your web traffic leaves the Tor network and is forwarded to your desired destination. The exit node is unable to see your IP address, but it does know what site it's connecting to.


1 Answers

This is a great question! Here's a short script for doing it using stem...

from stem import CircStatus
from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
  controller.authenticate()

  for circ in controller.get_circuits():
    if circ.status != CircStatus.BUILT:
      continue

    exit_fp, exit_nickname = circ.path[-1]

    exit_desc = controller.get_network_status(exit_fp, None)
    exit_address = exit_desc.address if exit_desc else 'unknown'

    print "Exit relay"
    print "  fingerprint: %s" % exit_fp
    print "  nickname: %s" % exit_nickname
    print "  address: %s" % exit_address
    print

Thanks for the question. I've added this to our FAQ.

like image 78
Damian Avatar answered Oct 27 '22 00:10

Damian