Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request new Tor identity from Windows command line

Tags:

windows

cmd

tor

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?

like image 882
BeMy Friend Avatar asked Aug 01 '15 06:08

BeMy Friend


Video Answer


2 Answers

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

like image 101
drew010 Avatar answered Sep 19 '22 16:09

drew010


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

like image 41
hac_lang Avatar answered Sep 17 '22 16:09

hac_lang