How to change the Tor exit node programmatically to get a new IP?

Viewed 52525

I have Tor running on my computer, and I need to change the Tor exit node every five minutes. For example, if I start using Tor via some exit node, then in 5 minutes I want Tor to change to an exit node with a different IP address. How can I do this?

Tor, as far as I know, is listening to port 8051 on localhost.

What commands can I send to this port to make Tor build a new chain, so that I can get another IP address?

11 Answers

yeah, that's 1 (i mean =true =))) that tor does change ip every 10 minutes but! if i restart tor - i'll get a new ip even in this 10minutes interval. so i was thinking about making tor to send this "change_ip" request manually. see this code (written according to http://en.linuxreviews.org/HOWTO_use_the_Internet_anonymously_using_Tor_and_Privoxy)

procedure ChangeIp;
var
  sck:TIdTCPClient;
begin
  sck:=TIdTCPClient.Create(nil);
  try
    sck.Host:='127.0.0.1';
    sck.Port:=10051;
    sck.Connect;
    sck.SendCmd('authenticate','');
    if sck.LastCmdResult.Code='250' then
    begin
      sck.SendCmd('signal newnym','');
    end;
  finally
    sck.Free;
  end;
end;

and accornig to [https://tor-svn.freehaven.net/svn/torctl/trunk/doc/howto.txt] i can write a controler that will change tor's conf on the fly. by default it is not enebled (i mean this ability), but i can make tor client listen to some port for accepting commands using torrc...if i'm not mistaken...again=)

!!! where the hell torrc is on my pc?

In C:\Users\geekman\AppData\Roaming\Tor i could,n fing it i got vista.

If you don't have access to the control port, you could use a different circuit which changes your IP*. This can be done by specifying a different socks username:

$ curl -x "socks5://circuit1@127.0.0.1:9050" "https://ifconfig.io/ip"
109.70.100.34

$ curl -x "socks5://circuit2@127.0.0.1:9050" "https://ifconfig.io/ip"
209.222.101.251

$ curl -x "socks5://circuit3@127.0.0.1:9050" "https://ifconfig.io/ip"
54.37.19.83

If you want to reuse a specific IP at some point you can use the same username you used before to get that IP again.

* The exit node will be random every time and there is a slight chance you'll get the same IP twice in a row.

Correct me if I'm wrong, I'm not a Tor expert, but this works for me.

You have no control over the routing in the tor network (if you had, someone could abuse this feature). But tor already switches the route roughly every 10 minutes (at least according to the German Wikipedia article).

Related