-
Notifications
You must be signed in to change notification settings - Fork 0
/
getpin.py
61 lines (49 loc) · 1.75 KB
/
getpin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Functions for logging in
import requests
import pyotp
import base64
import os
from cryptography.fernet import Fernet
FERNET_KEY = os.environ.get('FERNET_KEY') # This is a string
key_b = FERNET_KEY.encode('utf-8') # Convert to Bytes
CIPHER_SUITE = Fernet(FERNET_KEY)
def getActivationData(code):
HEADERS = {"User-Agent": "okhttp/3.11.0"}
PARAMS = {
"app_id": "com.duosecurity.duomobile.app.DMApplication",
"app_version": "2.3.3",
"app_build_number": "323206",
"full_disk_encryption": False,
"manufacturer": "Google",
"model": "Pixel",
"platform": "Android",
"jailbroken": False,
"version": "6.0",
"language": "EN",
"customer_protocol": 1,
}
ENDPOINT = "https://api-1b9bef70.duosecurity.com/push/v2/activation/{}"
res = requests.post(ENDPOINT.format(code), headers=HEADERS, params=PARAMS)
if res.json().get("code") == 40403:
print(
"Invalid activation code."
"Please request a new link in BoilerKey settings."
)
return None
if not res.json()["response"]:
print("Unknown error")
print(res.json())
return None
return res.json()["response"]
def get_password(user_data):
password = user_data.get('password')
password = CIPHER_SUITE.decrypt(password.value).decode('utf-8') # Decrypting password
if user_data.get('config'):
pin = password[:4]
config = user_data.get('config')
hotp = pyotp.HOTP(base64.b32encode(config["hotp_secret"].encode()))
hotpPassword = hotp.at(int(user_data.get('passwordAt', 0)))
password = "{},{}".format(pin, hotpPassword)
return password
if __name__== "__main__":
print('Please run the main file!')