Request new identity from Windows command line

限于喜欢 提交于 2019-11-29 04:38:20

问题


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?


回答1:


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.




回答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




回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/31758946/request-new-identity-from-windows-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!