2019-03-20 10:41:31 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-12-02 01:30:08 +00:00
|
|
|
|
2017-05-15 12:54:22 +00:00
|
|
|
import pyotp
|
|
|
|
import requests
|
|
|
|
import base64
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2019-10-02 21:52:50 +00:00
|
|
|
print("Usage: python duo_activate.py <url to duo qr>")
|
2019-03-20 10:41:31 +00:00
|
|
|
sys.exit()
|
2017-05-15 12:54:22 +00:00
|
|
|
|
|
|
|
qr_url = sys.argv[1]
|
|
|
|
|
2019-03-19 23:51:29 +00:00
|
|
|
host = 'api-%s' % (qr_url.split('/')[2].split('-')[1],)
|
2019-10-02 21:52:50 +00:00
|
|
|
code = qr_url.rsplit('/qr?value=',1)[1].split('-')[0]
|
2019-03-19 23:51:29 +00:00
|
|
|
|
|
|
|
url = 'https://{host}/push/v2/activation/{code}?customer_protocol=1'.format(host=host, code=code)
|
2019-10-02 21:52:50 +00:00
|
|
|
print("url", url)
|
2019-03-19 23:51:29 +00:00
|
|
|
headers = {'User-Agent': 'okhttp/2.7.5'}
|
|
|
|
data = {'jailbroken': 'false',
|
|
|
|
'architecture': 'armv7',
|
2019-10-02 21:52:50 +00:00
|
|
|
'region': 'NL',
|
2019-03-19 23:51:29 +00:00
|
|
|
'app_id': 'com.duosecurity.duomobile',
|
|
|
|
'full_disk_encryption': 'true',
|
|
|
|
'passcode_status': 'true',
|
|
|
|
'platform': 'Android',
|
2019-10-02 21:52:50 +00:00
|
|
|
'app_version': '3.29.1',
|
|
|
|
'app_build_number': '329101',
|
|
|
|
'version': '10.0',
|
2019-03-19 23:51:29 +00:00
|
|
|
'manufacturer': 'unknown',
|
|
|
|
'language': 'en',
|
2019-10-02 21:52:50 +00:00
|
|
|
'model': 'Command line',
|
|
|
|
'security_patch_level': '2019-10-01'}
|
2019-03-19 23:51:29 +00:00
|
|
|
|
|
|
|
r = requests.post(url, headers=headers, data=data)
|
2017-05-15 12:54:22 +00:00
|
|
|
response = json.loads(r.text)
|
|
|
|
|
2019-03-19 23:51:29 +00:00
|
|
|
try:
|
2019-10-02 21:52:50 +00:00
|
|
|
secret = base64.b32encode(response['response']['hotp_secret'].encode("UTF-8"))
|
2019-03-19 23:51:29 +00:00
|
|
|
except KeyError:
|
2019-03-20 10:41:31 +00:00
|
|
|
print(response)
|
2019-03-19 23:51:29 +00:00
|
|
|
sys.exit(1)
|
2017-05-15 12:54:22 +00:00
|
|
|
|
2019-03-20 10:41:31 +00:00
|
|
|
print("secret", secret)
|
2018-12-02 01:30:08 +00:00
|
|
|
|
|
|
|
f = open('duotoken.hotp', 'w')
|
2019-10-02 21:52:50 +00:00
|
|
|
f.write(secret.decode("UTF-8"))
|
|
|
|
f.write("\n0")
|
2018-12-02 01:30:08 +00:00
|
|
|
f.close()
|
|
|
|
|
2019-03-19 23:51:29 +00:00
|
|
|
with open('response.json', 'w') as resp:
|
|
|
|
resp.write(r.text)
|