Friday, May 1, 2015

How To Change TOR Browser IP or Identity with C# Without Password

In our previous post here we described what Tor is and how to change identity using Python.

Here we will discuss how to change Tor identity in C# environment.

First of all, if you write authentication method in C#, you have to set an password to access Tor. And you have to hash that password and put under torcc-default file. Which is sometimes not possible due to different reasons.

We can use another way to change Tor identity, which was told in previous post. We can just write that simple python script and put it somewhere in our computer. Then we can just invoke it using CommandShell or cmd.exe.

To do this, we have to install Python first, then some changes in path variable and then we are good to go.

1. Download and install Python. Here you can get Python 2.7.9 which is last version for Python2.
2. After installation completes, we have to add something to path variable. You can find tutorials on it with some googling. If you have installed 2.7.9 then add "C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;" to the PATH envitonment variable.
3. This enables running Python scripts by just typing python "file-name".

Then here is C#.Net part for calling cmd.exe asynchronously which will not interrupt our own process.

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C python c:\renew_tor.py";
process.StartInfo = startInfo;
process.Start();

Here renew_tor.py file contains python code to refresh Tor. You can find it here.

This way you don't have to authenticate with Tor.

Mehmet

No comments:

Post a Comment