Select specific node output in TOR (with Python code)

I want to write a simple script in Python that will connect to the TOR network and select the node output of the country that I specify. For example, I want all my outgoing network traffic to be redirected to say spain (via the TOR network). Is there any way to achieve this?

Thanks Tom.

+4
source share
2 answers

Well, I think I have an answer, this is not quite what I intended, but it works just as well.

TOR node, torrc, Robert Davey, python script , node. : https://tor.stackexchange.com/questions/327/how-may-i-run-multiple-tor-relay-instances-in-a-single-linux-machine

node , torrc TOR SIGHUP python :

from stem import Signal
from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
  controller.authenticate()
  controller.signal(Signal.HUP)
0

torrc . . :

import stem.process

tor_process = stem.process.launch_tor_with_config(
    tor_cmd = PATH_TO_TOR_LAUNCHER,
    config = {
        'SOCKSPort': str(SOCKS_PORT),
        'ControlPort': str(CTRL_PORT),
        'DataDirectory': DATA_DIR,
        'GeoIPFile': DATA_DIR + 'geoip',
        'GeoIPv6File': DATA_DIR + 'geoip6',
        'ExitNodes': '{es},{pt}'       # exiting through Spain or Portugal
        }
)

, Tor : http://dev.maxmind.com/geoip/legacy/codes/iso3166/

0

Source: https://habr.com/ru/post/1545880/


All Articles