Advertisement
Guest User

TwitterReport (v.1.0.3)

a guest
Nov 16th, 2015
9,284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.02 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #-*- coding: utf-8 -*-
  3. #
  4. # Name: TwitterReport (v.1.0.3)
  5. # About: Uses anon op queue system to report twitter accounts.
  6. # Credit: Based on script from @anonymous247742
  7. #
  8. # Requirements:
  9. # - Python 2.7
  10. # - Python Requests Module (http://stackoverflow.com/questions/17309288/importerror-no-module-named-requests)
  11. # - Splinter (http://splinter.readthedocs.org/en/latest/install.html)
  12. #
  13. # Usage:  python twitterReport.py -u YOUR_USER_NAME
  14. #
  15. # Linux/Unix:
  16. # - Linux Pip install instructions: http://pip.readthedocs.org/en/stable/installing/
  17. # - Requests module instructions: http://stackoverflow.com/questions/17309288/importerror-no-module-named-requests
  18. # - Splinter module instructions : http://splinter.readthedocs.org/en/latest/install.html
  19. #
  20. # Windows:
  21. # - Make sure pip is installed: http://pip.readthedocs.org/en/stable/installing/
  22. # - Open up cmd and run c:\python27\scripts\easy_install.exe request
  23. # - Get the zip : https://github.com/cobrateam/splinter/archive/master.zip unzip on your disk,
  24. # open a terminal (start menu -> type cmd -> launch cmd.exe)
  25. # go in the folder you unzip splinter (cd XXXX) launch 'python setup.py install'
  26. # - You may also need to open up cmd and run the following command: c:\python27\scripts\easy_install.exe request
  27. # if the requests module is not installed
  28. #
  29. # Need Help or Find a Bug?
  30. # - /join #OpParis - https://webchat.anonops.com/?channels=OpParis
  31. #
  32.  
  33. import sys
  34. try:
  35.     from splinter import Browser
  36. except:
  37.     print "Please install Splinter."
  38.     print "* Unix/Linux Use: sudo pip install splinter"
  39.     print "* Windows: See script's comments"
  40.     print "* More Info: http://splinter.readthedocs.org/en/latest/install.html"
  41.     sys.exit()
  42. try:
  43.     import requests
  44. except:
  45.     print "Please install the requests module."
  46.     print "* Unix/Linux Use: pip install requests"
  47.     print "* Windows in CMD: c:\python27\scripts\easy_install.exe request"
  48.     print "* More Info: http://stackoverflow.com/questions/17309288/importerror-no-module-named-requests"
  49.     sys.exit()
  50.    
  51. import getopt, re, time
  52. from datetime import datetime
  53. from splinter.request_handler.status_code import HttpResponseError
  54. import getpass
  55.  
  56. # Bot Variables
  57. o="opparis"
  58. op_srv="optools.anonops.com"
  59.  
  60. # Notifies target is offline
  61. def updatetarget(o,t):
  62.     try:
  63.         r = requests.get('http://'+op_srv+'/twUpdateTarget.php?o='+o+'&t='+t)
  64.         r.raise_for_status()
  65.     except HttpResponseError:
  66.         print "OP Server Error"
  67.  
  68. def main(argv):
  69.     d = datetime.now()
  70.     date = str(d.year) + '' + str(d.month) + '' + str(d.day) + '' + str(d.hour) + '' + str(d.minute) + '' + str(d.second)
  71.     username = None
  72.     try:
  73.         opts, args = getopt.getopt(argv,"h:u:",["user="])
  74.     except getopt.GetoptError:
  75.         print 'Usage: python twitterReport.py -u <Twitter username>'
  76.         sys.exit(2)
  77.  
  78.     for opt, arg in opts:
  79.         if opt == '-h':
  80.             print 'Usage: python twitterReport.py -u <Twitter username>'
  81.             sys.exit()
  82.         elif opt in ("-u", "--user"):
  83.             username = arg
  84.             n = username
  85.  
  86.     if not username:
  87.         print 'Usage: python twitterReport.py -u <Twitter username>'
  88.         sys.exit()
  89.  
  90.     password = getpass.getpass()
  91.  
  92. # comment this line if you want to use privoxy + tor:
  93.     with Browser() as browser:
  94. # uncomment this section if you want to use privoxy + tor:
  95. #    proxyIP = '127.0.0.1'
  96. #    proxyPort = 8118
  97. #
  98. #    proxy_settings = {'network.proxy.type': 1,
  99. #            'network.proxy.http': proxyIP,
  100. #            'network.proxy.http_port': proxyPort,
  101. #            'network.proxy.ssl': proxyIP,
  102. #            'network.proxy.ssl_port':proxyPort,
  103. #            'network.proxy.socks': proxyIP,
  104. #            'network.proxy.socks_port':proxyPort,
  105. #            'network.proxy.ftp': proxyIP,
  106. #            'network.proxy.ftp_port':proxyPort
  107. #            }
  108. #
  109. #    with Browser('firefox',profile_preferences=proxy_settings) as browser:
  110.         try:
  111.             browser.visit("https://twitter.com/login/")
  112.             time.sleep(1)
  113.             browser.execute_script("$('.js-username-field').val('%s');"  % (username))
  114.             browser.execute_script("$('.js-password-field').val('%s');" % (password))
  115.             browser.find_by_css("button[type='submit'].submit.btn.primary-btn").click()
  116.             time.sleep(1)
  117.  
  118.             if "https://twitter.com/login/error" in browser.url:
  119.                 print "Twitter Login Failed!"
  120.                 sys.exit()
  121.  
  122.         except:
  123.             print "Unexpected error occured while trying the Twitter login. Please try running the script again."
  124.             sys.exit()
  125.  
  126.         while True:
  127.             try:
  128.                 time.sleep(1)
  129.                 # Get target from target queue
  130.                 tg = ""
  131.                 t = requests.get('http://'+op_srv+'/twGetTarget.php?o='+o+'&n='+n)
  132.                 tg = t.content
  133.                 if tg == "" or tg == "noassignment" or ("error" in tg) or ("What happened?" in tg) or ("CloudFlare" in tg) or ("Cloudflare" in tg) or ("Checking your browser" in tg):
  134.                     print "No current assignment"
  135.                     time.sleep(3)
  136.                 else:
  137.                     browser.visit("https://twitter.com/"+tg)
  138.                     if not browser.is_element_present_by_css('.route-account_suspended') and not browser.is_element_present_by_css('.search-404'):
  139.                         browser.find_by_css('.user-dropdown').click()
  140.                         browser.find_by_css('li.report-text button[type="button"]').click()
  141.                         with browser.get_iframe('new-report-flow-frame') as iframe:
  142.                             iframe.find_by_css("input[type='radio'][value='abuse']").check()
  143.                         browser.find_by_css('.new-report-flow-next-button').click()
  144.                         with browser.get_iframe('new-report-flow-frame') as iframe:
  145.                             iframe.find_by_css("input[type='radio'][value='harassment']").check()
  146.                         browser.find_by_css('.new-report-flow-next-button').click()
  147.                         with browser.get_iframe('new-report-flow-frame') as iframe:
  148.                             iframe.find_by_css("input[type='radio'][value='Someone_else']").check()
  149.                         browser.find_by_css('.new-report-flow-next-button').click()
  150.                         with browser.get_iframe('new-report-flow-frame') as iframe:
  151.                             iframe.find_by_css("input[type='radio'][value='violence']").check()
  152.                         browser.find_by_css('.new-report-flow-next-button').click()
  153.                         try:
  154.                             followers = browser.find_by_css('a[data-nav="followers"] .ProfileNav-value').value;
  155.                         except:
  156.                             followers = ""
  157.                         msg = tg+' - ' + followers + ' Followers'
  158.                     elif browser.is_element_present_by_css('.route-account_suspended'):
  159.                         msg =  tg+' - Suspended'
  160.                         updatetarget(o,tg)
  161.                     elif browser.is_element_present_by_css('.search-404'):
  162.                         msg =  tg+' - Does not exist'
  163.                         updatetarget(o,tg)
  164.                     else:
  165.                         msg = tg+' - Unknown'
  166.                         updatetarget(o,tg)
  167.  
  168.                     print msg
  169.             except KeyboardInterrupt:
  170.                 print 'Quit by keyboard interrupt sequence!'
  171.                 break
  172.             except HttpResponseError, e:
  173.                 msg = 'HttpResponseError'
  174.                 print msg
  175.                 with open("log_Error.txt", "a") as log:
  176.                     log.write(msg+"\n")
  177.             except:
  178.                 msg = 'CatchAllError'
  179.                 print msg
  180.                 with open("log_Error.txt", "a") as log:
  181.                     log.write(msg+"\n")
  182.  
  183. if __name__ == "__main__":
  184.     try:
  185.         main(sys.argv[1:])
  186.     except KeyboardInterrupt:
  187.         sys.stdout.write('\nQuit by keyboard interrupt sequence!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement