# -*- coding: utf-8 -*-
# androidkindlekey.py
-# Copyright © 2010-20 by Thom, Apprentice et al.
+# Copyright © 2010-20 by Thom, Apprentice Harper et al.
# Revision history:
# 1.0 - AmazonSecureStorage.xml decryption to serial number
import zlib
import tarfile
from hashlib import md5
-try:
- from cStringIO import StringIO
-except ImportError:
- from io import BytesIO as StringIO
+from io import BytesIO
from binascii import a2b_hex, b2a_hex
# Routines common to Mac and PC
cipher = self._get_cipher()
padding = len(self.key) - len(plaintext) % len(self.key)
plaintext += chr(padding) * padding
- return b2a_hex(cipher.encrypt(plaintext))
+ return b2a_hex(cipher.encrypt(plaintext.encode('utf-8')))
def decrypt(self, ciphertext):
cipher = self._get_cipher()
obfuscation = AndroidObfuscation()
def get_value(key):
- encrypted_key = obfuscation.encrypt(a2b_hex(key))
+ encrypted_key = obfuscation.encrypt(key)
encrypted_value = storage.get(encrypted_key)
if encrypted_value:
return obfuscation.decrypt(encrypted_value)
try:
tokens = set(get_value('kindle.account.tokens').split(','))
except:
+ sys.stderr.write('cannot get kindle account tokens\n')
return []
serials = []
serials = []
for x in dsns:
+ serials.append(x)
for y in tokens:
- serials.append(x)
serials.append(y)
serials.append(x+y)
return serials
read = open(path, 'rb')
head = read.read(24)
if head[:14] == b'ANDROID BACKUP':
- output = StringIO(zlib.decompress(read.read()))
+ output = BytesIO(zlib.decompress(read.read()))
except Exception:
pass
finally:
if len(keys) > 0:
with open(outfile, 'w') as keyfileout:
for key in keys:
- keyfileout.write(b2a_hex(key))
+ keyfileout.write(key)
keyfileout.write("\n")
return True
return False
import tkinter.filedialog
except:
print("tkinter not installed")
- return cli_main()
+ return 0
class DecryptionDialog(tkinter.Frame):
def __init__(self, root):