DeGourou/setup/loginAccount.py

80 lines
2.1 KiB
Python
Raw Permalink Normal View History

2023-02-23 18:09:08 +11: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-24 05:42:15 +11:00
from decrypt.params import KEYPATH
2023-02-23 18:09:08 +11:00
#################################################################
2023-02-27 01:00:51 +11:00
def loginAndGetKey(email, password):
2023-02-23 18:09:08 +11:00
global VAR_MAIL
global VAR_PASS
global VAR_VER
global KEYPATH
# acc files
2023-02-24 05:42:15 +11:00
if True:
2023-02-23 18:09:08 +11:00
2023-02-27 01:00:51 +11:00
VAR_MAIL = email
VAR_PASS = password
2023-02-23 18:09:08 +11:00
print("Logging in")
createDeviceKeyFile()
success = createDeviceFile(True, VAR_VER)
if (success is False):
print("Error, couldn't create device file.")
2023-02-27 01:00:51 +11:00
return
2023-02-23 18:09:08 +11:00
success, resp = createUser(VAR_VER, None)
if (success is False):
print("Error, couldn't create user: %s" % resp)
2023-02-27 01:00:51 +11:00
return
2023-02-23 18:09:08 +11:00
success, resp = signIn("AdobeID", VAR_MAIL, VAR_PASS)
if (success is False):
print("Login unsuccessful: " + resp)
2023-02-27 01:00:51 +11:00
return
2023-02-23 18:09:08 +11:00
success, resp = activateDevice(VAR_VER, None)
if (success is False):
print("Couldn't activate device: " + resp)
2023-02-27 01:00:51 +11:00
return
2023-02-23 18:09:08 +11: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-27 01:00:51 +11:00
return
2023-02-23 18:09:08 +11:00
print("Successfully exported key for account " + VAR_MAIL + " to file " + filename)
else:
print("failed")
2023-02-27 01:00:51 +11:00
2023-02-23 18:09:08 +11:00
except Exception as e:
print(e)
2023-02-27 01:00:51 +11:00
2023-02-23 18:09:08 +11:00
print('All Set')
print()