Advertisement
infodox

newnym.py

Jan 26th, 2013
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Original author: github.com/ohdae
  3. # --time flag added by @info_dox
  4. # Get new TOR Identity
  5.  
  6. import telnetlib
  7. import time, argparse
  8.  
  9. def newnym(host, port, pw):
  10.     tn = telnetlib.Telnet(host, port)
  11.     tn.write(('AUTHENTICATE "%s"\r\n' % pw ))
  12.     res = tn.read_until('250 OK', 5)
  13.     if res.find('250 OK') > -1:
  14.        print('AUTHENICATE accepted.')
  15.     tn.write("signal NEWNYM\r\n")
  16.     res = tn.read_until('250 OK', 5)
  17.     if res.find('250 OK') > -1:
  18.        print("[+] New identity successfull")
  19.  
  20. def main():
  21.     while True:
  22.         newnym(host, port, pw)
  23.         print("[+] New identity in %s seconds...") %(tim)
  24.         time.sleep(tim)
  25.    
  26.  
  27. help = """Utilizes telnetlib to change TOR identities"""
  28.  
  29. parser = argparse.ArgumentParser(description=help)
  30. parser.add_argument("--host", help="hostname, usually localhost", default="localhost")
  31. parser.add_argument("--port", help="TOR control port", type=int, default=9051)
  32. parser.add_argument("--pw", help="Control password", required=True)
  33. parser.add_argument("--time", help="Time between newnyms", type=int, default=90)
  34. args = parser.parse_args()
  35.  
  36. port = args.port
  37. host = args.host
  38. pw = args.pw
  39. tim = args.time
  40.  
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement