10

I'm trying to use a simple Windows Command Line command to change TOR identities. I see plenty of examples for Linux, but not sure how to implement the same thing on Windows.

Anyone have any ideas?

numX
  • 830
  • 7
  • 24
BeMy Friend
  • 751
  • 1
  • 6
  • 11

4 Answers4

14

UPDATE: Using stream isolation as shown in this answer may be a way to get around needing to use the control port to request a new identity. Using a username & password on the SOCKS connection isolates those requests to a specific circuit and changing the credentials will automatically change the circuit which results in getting a new IP.

To create a new circuit (switch IP addresses) on Windows without stopping and starting Tor, you need to open a connection to Tor's control port to issue a NEWNYM signal.

Here is a batch file that will achieve this. You also need to download netcat for Windows and put nc.exe in the same folder as this batch file.

I downloaded the Tor Browser Bundle for Windows, so you will need to put this batch file in the root folder of the browser bundle.

@echo off

REM Read control auth cookie into variable
set /p auth_cookie=<Browser\TorBrowser\Data\Tor\control_auth_cookie

REM Create file with control commands
echo AUTHENTICATE "%auth_cookie%"> commands.txt
echo SIGNAL NEWNYM>> commands.txt
echo QUIT>> commands.txt

REM Connect to control port and issue commands
nc localhost 9151 < commands.txt

REM Delete commands file
del /Q commands.txt

I tested this on Windows and after running the batch file, my circuit changed and I had a new IP each time.

When you run it, you should see the following output:

C:\Users\user\Desktop\Tor Browser>control.bat
250 OK   <-- in response to AUTHENTICATE
250 OK   <-- in response to SIGNAL NEWNYM
250 closing connection

There is no simple one-liner, you have to connect to the control port and issue this signal. This is what the browser does when you press the new identity button.

Here is the directory structure relative to the Tor Browser Bundle, nc, and the batch file to create a new circuit.

file structure

drew010
  • 68,777
  • 11
  • 134
  • 162
  • 1
    I know it's a bit late on this... other things came up. But I get errors: 515 Authentication failed: Password did not match HashedControlPassword *or* authentication cookie. The cookie file is saved, but I guess the contents don't match. – BeMy Friend Aug 15 '15 at 04:52
  • 1
    I would double check that the bat file has the correct path to the cookie and is reading the right thing (or anything). Most likely its something simple and the cookie file is in a slightly different place. – drew010 Aug 15 '15 at 17:25
  • 2020 now and control_auth_cookie no longer here. – IT-Fan May 09 '20 at 23:58
2
  1. Change tor control panel authentication method to "Password" (Settings | Advanced in Vidalia control center) Example picture

  2. Download Netcat for Windows

  3. Create text file with commands for netcat with name tor-change.txt

AUTHENTICATE "your password from control panel here" SIGNAL NEWNYM QUIT

  1. Create .cmd file which will change ip on every start:

@echo off nc localhost 9151 < tor-change.txt

bald2b
  • 179
  • 1
  • 6
1
My configuration environment: Win10 + Tor8.0.4

@drew010 Sorry, I need to improve your answer. Thank you for your answer. Because I am executing the bat file in your answer, an error will occur. I get the following error: Example picture Link:Error.png

C:\Users\Username\Desktop\Tor Browser>control.bat
The system can not find the file specified.
515 Authentication failed: Password did not match HashedControlPassword value from 
configuration

To create a new circuit (switch IP addresses) on Windows without stopping and starting Tor, you need to open a connection to Tor's control port to issue a NEWNYM signal.

Here is a batch file that will achieve this. You also need to download netcat for Windows and put nc.exe in the same folder as this batch file.

I downloaded the Tor Browser Bundle for Windows, so you will need to put this batch file in the root folder of the browser bundle.

@echo off

REM Create file with control commands
echo AUTHENTICATE "password">> commands.txt
echo SIGNAL NEWNYM>> commands.txt
echo QUIT>> commands.txt

REM Connect to control port and issue commands
nc localhost 9051 < commands.txt

REM Delete commands file
del /Q commands.txt

I often don't output hash values when I execute tor.exe --hash-password "password" | more don't worry, try a few more times, or try again after restarting tor*

The file involved: 【torrc】【control.bat】【nc.exe】as shown below: Example picture Link:config.png

ControlPort 9051
CookieAuthentication 1
HashedControlPassword 16:7D16C25CC12983446033B921EFFCD3E9E734FBDF8D4B9F152A69B2983C

The final effect: perform a "control.bat" once to change ip: Example picture Link:enter.png

hac_lang
  • 11
  • 4
0

Did you mean to change TOR identity while TOR browser is still running?
Or you can terminate and restart TOR with cmd command instead. start PATH\firefox.exe
By the way, if you don't mind to programmatically change identities/IP using Python script, take a look here: http://mehmetkurtipek.blogspot.com/2015/05/how-to-change-tor-browser-ip-or.html and here: Python - Controlling Tor

Community
  • 1
  • 1
Happy Face
  • 1,061
  • 7
  • 18
  • Terminating the program using taskkill is causing issues which causes TOR to prompt the user to go into safe mode. Once that happens, the script can't re-open TOR as it's waiting on user input. If I can just switch the identity with a command, that should correct the issue. I'll look at your post – BeMy Friend Aug 01 '15 at 07:54