Support multiple keys on MacOS

This commit is contained in:
Giovanni Carvelli 2024-05-19 18:54:18 -04:00
parent 3373d93874
commit 763ddb81e2
1 changed files with 28 additions and 22 deletions

View File

@ -379,40 +379,46 @@ elif isosx:
return None return None
def adeptkeys(): def adeptkeys():
# TODO: All the code to support extracting multiple activation keys
# TODO: seems to be Windows-only currently, still needs to be added for Mac.
actpath = findActivationDat() actpath = findActivationDat()
if actpath is None: if actpath is None:
raise ADEPTError("Could not find ADE activation.dat file.") raise ADEPTError("Could not find ADE activation.dat file.")
tree = etree.parse(actpath) tree = etree.parse(actpath)
adept = lambda tag: '{%s}%s' % (NSMAP['adept'], tag) adept = lambda tag: '{%s}%s' % (NSMAP['adept'], tag)
expr = '//%s/%s' % (adept('credentials'), adept('privateLicenseKey')) expr = '//%s/%s' % (adept('credentials'), adept('privateLicenseKey'))
userkey = tree.findtext(expr) userkeyelems = tree.findall(expr)
exprUUID = '//%s/%s' % (adept('credentials'), adept('user')) userkeys = []
keyName = "" keynames = []
try: for userkeyelem in userkeyelems:
keyName = tree.findtext(exprUUID)[9:] + "_" userkey = userkeyelem.text
except:
pass
try: exprUUID = '//%s/%s' % (adept('credentials'), adept('user'))
exprMail = '//%s/%s' % (adept('credentials'), adept('username')) keyName = ""
keyName = keyName + tree.find(exprMail).attrib["method"] + "_" try:
keyName = keyName + tree.findtext(exprMail) + "_" keyName = tree.findtext(exprUUID)[9:] + "_"
except: except:
pass pass
if keyName == "": try:
keyName = "Unknown" exprMail = '//%s/%s' % (adept('credentials'), adept('username'))
else: keyName = keyName + tree.find(exprMail).attrib["method"] + "_"
keyName = keyName[:-1] keyName = keyName + tree.findtext(exprMail) + "_"
except:
pass
if keyName == "":
keyName = "Unknown"
else:
keyName = keyName[:-1]
userkey = b64decode(userkey)
userkey = userkey[26:]
userkey = b64decode(userkey) userkeys.append(userkey)
userkey = userkey[26:] keynames.append(keyName)
return [userkey], [keyName]
print("Found {0:d} keys".format(len(userkeys)))
return userkeys, keynames
else: else:
def adeptkeys(): def adeptkeys():