Skip to content

Instantly share code, notes, and snippets.

@gerardo
Created October 11, 2012 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerardo/3874037 to your computer and use it in GitHub Desktop.
Save gerardo/3874037 to your computer and use it in GitHub Desktop.
def renewTorIdentity(passAuth):
try:
s = socket.socket()
s.connect(('localhost', 9051))
s.send('AUTHENTICATE "{0}"\r\n'.format(passAuth))
resp = s.recv(1024)
if resp.startswith('250'):
s.send("signal NEWNYM\r\n")
resp = s.recv(1024)
if resp.startswith('250'):
print "Identity renewed"
else:
print "response 2:", resp
else:
print "response 1:", resp
s.close()
except Exception as e:
print "Can't renew identity: ", e
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment