Skip to content

Instantly share code, notes, and snippets.

@starenka
Forked from ehmo/gist:1349819
Created September 26, 2012 11:15
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 starenka/3787412 to your computer and use it in GitHub Desktop.
Save starenka/3787412 to your computer and use it in GitHub Desktop.
Request a new IP address from TOR in Python
def NewTorIP():
s = socket.socket()
s.connect(('localhost', 9051))
s.send("AUTHENTICATE\r\n")
r = s.recv(1024)
if r.startswith('250'):
s.send("signal NEWNYM\r\n")
r = s.recv(1024)
if r.startswith('250'):
return True
else:
return False
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment