Created
July 11, 2015 10:02
-
-
Save angelovstanton/974855f68267b8062d4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void RefreshTorIdentity() | |
{ | |
Socket server = null; | |
try | |
{ | |
IPEndPoint ip = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9151); | |
server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | |
server.Connect(ip); | |
server.Send(Encoding.ASCII.GetBytes("AUTHENTICATE \"johnsmith\"" + Environment.NewLine)); | |
byte[] data = new byte[1024]; | |
int receivedDataLength = server.Receive(data); | |
string stringData = Encoding.ASCII.GetString(data, 0, receivedDataLength); | |
server.Send(Encoding.ASCII.GetBytes("SIGNAL NEWNYM" + Environment.NewLine)); | |
data = new byte[1024]; | |
receivedDataLength = server.Receive(data); | |
stringData = Encoding.ASCII.GetString(data, 0, receivedDataLength); | |
if (!stringData.Contains("250")) | |
{ | |
Console.WriteLine("Unable to signal new user to server."); | |
server.Shutdown(SocketShutdown.Both); | |
server.Close(); | |
} | |
} | |
finally | |
{ | |
server.Close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could make line 9 contain "your_password" instead of "johnsmith" so it matches the "tor.exe –hash-password “your_password”" from the blog.