DeGourou/setup/loginAccount.py

80 lines
2.1 KiB
Python
Raw Normal View History

2023-02-23 08:09:08 +01:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
This is an experimental Python version of libgourou.
'''
from setup.libadobe import createDeviceKeyFile, FILE_DEVICEKEY, FILE_DEVICEXML, FILE_ACTIVATIONXML
from setup.libadobeAccount import createDeviceFile, createUser, signIn, activateDevice, exportAccountEncryptionKeyDER, getAccountUUID
from os.path import exists
VAR_MAIL = ""
VAR_PASS = ""
VAR_VER = 1 # None # 1 for ADE2.0.1, 2 for ADE3.0.1
2023-02-23 19:42:15 +01:00
from decrypt.params import KEYPATH
2023-02-23 08:09:08 +01:00
#################################################################
2023-02-26 15:00:51 +01:00
def loginAndGetKey(email, password):
2023-02-23 08:09:08 +01:00
global VAR_MAIL
global VAR_PASS
global VAR_VER
global KEYPATH
# acc files
2023-02-23 19:42:15 +01:00
if True:
2023-02-23 08:09:08 +01:00
2023-02-26 15:00:51 +01:00
VAR_MAIL = email
VAR_PASS = password
2023-02-23 08:09:08 +01:00
print("Logging in")
createDeviceKeyFile()
success = createDeviceFile(True, VAR_VER)
if (success is False):
print("Error, couldn't create device file.")
2023-02-26 15:00:51 +01:00
return
2023-02-23 08:09:08 +01:00
success, resp = createUser(VAR_VER, None)
if (success is False):
print("Error, couldn't create user: %s" % resp)
2023-02-26 15:00:51 +01:00
return
2023-02-23 08:09:08 +01:00
success, resp = signIn("AdobeID", VAR_MAIL, VAR_PASS)
if (success is False):
print("Login unsuccessful: " + resp)
2023-02-26 15:00:51 +01:00
return
2023-02-23 08:09:08 +01:00
success, resp = activateDevice(VAR_VER, None)
if (success is False):
print("Couldn't activate device: " + resp)
2023-02-26 15:00:51 +01:00
return
2023-02-23 08:09:08 +01:00
print("Authorized to account " + VAR_MAIL)
# KEY
if not exists(KEYPATH):
print("Exporting keys ...")
try:
account_uuid = getAccountUUID()
if (account_uuid is not None):
filename = KEYPATH
success = exportAccountEncryptionKeyDER(filename)
if (success is False):
print("Couldn't export key.")
2023-02-26 15:00:51 +01:00
return
2023-02-23 08:09:08 +01:00
print("Successfully exported key for account " + VAR_MAIL + " to file " + filename)
else:
print("failed")
2023-02-26 15:00:51 +01:00
2023-02-23 08:09:08 +01:00
except Exception as e:
print(e)
2023-02-26 15:00:51 +01:00
2023-02-23 08:09:08 +01:00
print('All Set')
print()