Advertisement
parrotsecurity

[Python] TOR traffic generator

Jan 18th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. """
  4. Before you run this project, you need 2 have TOR installed and the modules.
  5.  
  6. Ubuntu: apt-get install tor / Debian: yum install tor
  7.  
  8. I'm Not responsible for illegal activities
  9.  
  10.          parrotsecurity 2k17
  11. """
  12.  
  13. import socket
  14. import socks
  15. import urllib2
  16. import os
  17. import time
  18. import sys
  19.  
  20. if not os.geteuid() == 0:
  21.     sys.exit('[!] Script must be run as root [!]')
  22.  
  23. os.system("service tor start")
  24.  
  25. print "Format like (http://example.com?id=whatever && http://example.com)"
  26. URL = raw_input("To what URL u wanna generate traffic: ")
  27.  
  28. try:
  29.     while 1:
  30.         # IP SERVER
  31.         ipcheck_url = 'http://checkip.amazonaws.com/'
  32.         yourip = urllib2.urlopen(ipcheck_url).read()
  33.         print "IP OF SERVER WAS: " + yourip
  34.  
  35.  
  36.         # TOR IP.
  37.         socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9050)
  38.         socket.socket = socks.socksocket
  39.         socksip = urllib2.urlopen(ipcheck_url).read()
  40.         print "IP OF THE SOCKS NOW: " + socksip
  41.         req=urllib2.Request(url=URL,headers={'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113'})
  42.         urllib2.urlopen(req)
  43.         os.system("service tor restart") # new ip addr request
  44.         time.sleep(1)
  45.  
  46. except socks.ProxyConnectionError:
  47.     print "[X] Can't make any connection on port 9050 [X]"
  48.     print "Are you sure TOR is running in deamon?"
  49.     print "service tor start\n"
  50.  
  51. except KeyboardInterrupt:
  52.     print "[X] Program stopped [X]"
  53.  
  54. except urllib2.HTTPError:
  55.     print "[X] Are you sure this is the correct url? [X]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement