Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #-*- coding: utf-8 -*-
  3. try:
  4. from splinter import Browser
  5. except:
  6. print "Please install Splinter: http://splinter.readthedocs.org/en/latest/install.html"
  7. sys.exit()
  8.  
  9. try:
  10. from stem.control import Controller
  11. except:
  12. print "Please install Stem: https://stem.torproject.org"
  13. sys.exit()
  14.  
  15.  
  16. import sys, getopt, re, os
  17. from stem.control import Controller
  18. from datetime import datetime
  19. from splinter.request_handler.status_code import HttpResponseError
  20. import getpass
  21.  
  22.  
  23. def main(argv):
  24. d = datetime.now()
  25. date = str(d.year) + '' + str(d.month) + '' + str(d.day) + '' + str(d.hour) + '' + str(d.minute) + '' + str(d.second)
  26. username = None
  27. txt = None
  28. try:
  29. opts, args = getopt.getopt(argv, "hi:u:", ["file=", "user=", "help"])
  30. except getopt.GetoptError:
  31. print 'Use --help for help'
  32. sys.exit(2)
  33.  
  34. for opt, arg in opts:
  35. if opt in ("-h", "--help"):
  36. print 'Usage: %s <options> \n' % (os.path.basename(__file__))
  37. print ' -h, --help This help'
  38. print ' -u, --user USERNAME Your Twitter username'
  39. print ' -f, --file FILE File with twitter URLs list'
  40. sys.exit()
  41. elif opt in ("-i", "--file"):
  42. txt = arg
  43. elif opt in ("-u", "--user"):
  44. username = arg
  45.  
  46. if not username and not txt:
  47. print 'Use --help for help\n'
  48. print 'Usage: python twitterReport.py -u <Twitter username> -i <account_list.txt>'
  49. print 'The accounts list must have only 1 account per line'
  50. sys.exit()
  51.  
  52. password = getpass.getpass()
  53.  
  54. # uncomment this section if you want to use privoxy + tor:
  55. #
  56.  
  57. if __name__ == "__main__":
  58.  
  59.  
  60. port = 5000
  61. host = "127.0.0.1"
  62. hidden_svc_dir = "c:/temp/"
  63.  
  64. @app.route('/')
  65. def index():
  66. return "<h1>Tor works!</h1>"
  67. print " * Getting controller"
  68. controller = Controller.from_port(address="127.0.0.1", port=9151)
  69. try:
  70. controller.authenticate(password="")
  71. controller.set_options([
  72. ("HiddenServiceDir", hidden_svc_dir),
  73. ("HiddenServicePort", "80 %s:%s" % (host, str(port)))
  74. ])
  75. svc_name = open(hidden_svc_dir + "/hostname", "r").read().strip()
  76. print " * Created host: %s" % svc_name
  77. except Exception:
  78. print e
  79. app.run()
  80. if "https://twitter.com/login/error" in browser.url:
  81. print "The email and password you entered did not match our records."
  82. sys.exit()
  83. for line in file:
  84. try:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement