Last active
January 29, 2025 21:48
-
-
Save H0neyBadger/59612725b3481c763759a8f64baf3952 to your computer and use it in GitHub Desktop.
decrypt alexa android app map_data_storage_v2.db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
from Crypto import Random | |
from Crypto.Cipher import AES | |
import sqlite3 | |
from pprint import pprint | |
def dict_factory(cursor, row): | |
d = {} | |
for idx, col in enumerate(cursor.description): | |
d[col[0]] = row[idx] | |
return d | |
class AESCipher(object): | |
def __init__(self, key): | |
self.bs = AES.block_size | |
self.key = base64.b64decode(key) | |
def decrypt(self, enc): | |
iv = enc[: AES.block_size] | |
cipher = AES.new(self.key, AES.MODE_CBC, iv) | |
return AESCipher._unpad(cipher.decrypt(enc[AES.block_size :])).decode("utf-8") | |
@staticmethod | |
def _unpad(s): | |
return s[: -ord(s[len(s) - 1 :])] | |
con = sqlite3.connect("map_data_storage_v2.db") | |
con.row_factory = dict_factory | |
cur = con.cursor() | |
cur.execute("select * from encryption_data") | |
# fetch aes key | |
key = cur.fetchone()["encryption_data_value"].strip("\n") | |
cur.execute("select * from device_data") | |
cipher = AESCipher(key) | |
data = [ | |
data | {"device_data_value": cipher.decrypt(data["device_data_value"])} | |
for data in cur.fetchall() | |
] | |
pprint(data) | |
cur.execute("select * from account_data") | |
cipher = AESCipher(key) | |
data = [ | |
data | {"account_data_value": cipher.decrypt(data["account_data_value"])} | |
for data in cur.fetchall() | |
] | |
pprint(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment