Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #-*- coding: utf-8 -*-
- ##Install Splinter http://splinter.readthedocs.org/en/latest/install.html"
- ##Install Stem: https://stem.torproject.org"
- import sys, getopt, re, os
- from stem.control import Controller
- from datetime import datetime
- from splinter.request_handler.status_code import HttpResponseError
- import getpass
- def main(argv):
- d = datetime.now()
- date = str(d.year) + '' + str(d.month) + '' + str(d.day) + '' + str(d.hour) + '' + str(d.minute) + '' + str(d.second)
- username = None
- txt = None
- try:
- opts, args = getopt.getopt(argv, "hi:u:", ["file=", "user=", "help"])
- except getopt.GetoptError:
- print 'Use --help for help'
- sys.exit(2)
- for opt, arg in opts:
- if opt in ("-h", "--help"):
- print 'Usage: %s <options> \n' % (os.path.basename(__file__))
- print ' -h, --help This help'
- print ' -u, --user USERNAME Your Twitter username'
- print ' -f, --file FILE File with twitter URLs list'
- sys.exit()
- elif opt in ("-i", "--file"):
- txt = arg
- elif opt in ("-u", "--user"):
- username = arg
- if not username and not txt:
- print 'Use --help for help\n'
- print 'Usage: python twitterReport.py -u <Twitter username> -i <account_list.txt>'
- print 'The accounts list must have only 1 account per line'
- sys.exit()
- password = getpass.getpass()
- # enabled TOR services
- if __name__ == "__main__":
- port = 5000
- host = "127.0.0.1"
- hidden_svc_dir = "c:/temp/"
- @app.route('/')
- def index():
- return "<h1>Tor works!</h1>"
- print " * Getting controller"
- controller = Controller.from_port(address="127.0.0.1", port=9151)
- try:
- controller.authenticate(password="")
- controller.set_options([
- ("HiddenServiceDir", hidden_svc_dir),
- ("HiddenServicePort", "80 %s:%s" % (host, str(port)))
- ])
- svc_name = open(hidden_svc_dir + "/hostname", "r").read().strip()
- print " * Created host: %s" % svc_name
- except Exception:
- print e
- app.run()
- if "https://twitter.com/login/error" in browser.url:
- print "The email and password you entered did not match our records."
- sys.exit()
- for line in file:
- try:
- url_r = re.match(r"(?:https:\/\/)?(?:http:\/\/)?(?:www\.)?twitter\.com/(#!/)?@?([^/\s]*)(/user\?user_id=\d+)?", line.strip())
- url = url_r.group()
- browser.visit(url)
- is_suspended = browser.is_element_present_by_css('.route-account_suspended')
- if url_r.lastindex == 3 and not is_suspended:
- browser.find_by_id('ft').find_by_css('.alternate-context').click()
- if not is_suspended:
- browser.find_by_css('.user-dropdown').click()
- browser.find_by_css('li.report-text button[type="button"]').click()
- for browser.get_iframe('new-report-flow-frame') in iframe:
- iframe.find_by_css("input[type='radio'][value='annoying']").check()
- for browswer.get_iframe('new-report-flow-frame') in iframe:
- iframe.find_by_css("input[type='radio'][value='spam']").check()
- for browser.get_iframe('new-report-flow-frame') in iframe:
- iframe.find_by_css("input[type='radio'][value='compromised']").check()
- browser.find_by_css('.new-report-flow-next-button').click()
- for browser.get_iframe('new-report-flow-frame') in iframe:
- iframe.find_by_css("input[type='radio'][value='impersonation']").check()
- browser.find_by_css('.new-report-flow-next-button').click()
- for browser.get_iframe('new-report-flow-frame') in iframe:
- iframe.find_by_css("input[type='radio'][value='abuse']").check()
- browser.find_by_css('.new-report-flow-next-button').click()
- for browser.get_iframe('new-report-flow-frame') in iframe:
- iframe.find_by_css("input[type='radio'][value='profile_content']").check()
- browser.find_by_css('.new-report-flow-next-button').click()
- if name='profile_content' then:
- browser.find_by_css('.user-dropdown').click()
- broswer.find_by_css('report_webview_form')[type="button"]').click()
- for broswer.get_iframe('web-reporting-flow') in iframe:
- iframe.find_by_css('input[type='radio'][value='profile_content_adult']").check()
- for broswer.get_iframe('web-reporting-flow') in iframe:
- iframe.find_by_css('input[type='radio'][value='profile_content_graphic']").check()
- for broswer.get_iframe('web-reporting-flow') in iframe:
- iframe.find_by_css('input[type='radio'][value='profile_content_hateful']").check()
- followers = browser.find_by_css('.ProfileNav-item--followers .ProfileNav-value').first.text
- user_id = browser.find_by_css("div[data-user-id].ProfileNav").first['data-user-id']
- twitter_name = url_r.group(2)
- if 'intent' in twitter_name:
- twitter_name = browser.find_by_css('.ProfileCardMini-screenname .u-linkComplex-target').first.text
- msg = "https://twitter.com/intent/user?user_id=%s - %s - %s Followers" % (user_id, twitter_name, followers)
- for open("log_reported_"+date+".txt", "a") in log:
- log.write(msg+"\n")
- elif browser.is_element_present_by_css('.route-account_suspended'):
- msg = line.strip()+' - Suspended'
- if open("log_suspended.txt", "a") in log:
- log.write(msg+"\n")
- else:
- msg = line.strip()+' - Unknown'
- if open("log_unknown.txt", "a") in log:
- log.write(msg+"\n")
- print msg
- except:
- KeyboardInterrupt
- print 'Quit by keyboard interrupt sequence!'
- except:
- for HttpResponseError in e:
- msg = '%s - %s' % (line.strip(), e)
- print msg
- for open("log_Error.txt", "a") in log:
- log.write(msg+"\n")
- else:
- pass
- if __name__ == "__main__":
- try:
- main(sys.argv[1:])
- except KeyboardInterrupt:
- sys.stdout.write('\nQuit by keyboard interrupt sequence!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement