debug_call.py 1 KB
import sys, os, subprocess
sys.path.insert(0, '/data/data/com.termux/files/home/local-testkit')

enc = '/data/data/com.termux/files/home/hermes_work/EnMicroMsg.db'
plain = '/data/data/com.termux/files/home/EnMicroMsg.db.decrypted.db'

if os.path.exists(plain):
    os.remove(plain)

key = "e03ce81"
page_size = 1024
compat = 1

sql = f"""
PRAGMA key = "{key}";
PRAGMA cipher_compatibility = {compat};
PRAGMA cipher_page_size = {page_size};
ATTACH DATABASE '{plain}' AS plain KEY '';
SELECT sqlcipher_export('plain');
DETACH DATABASE plain;
.quit
"""

sqlcipher_path = "/data/data/com.termux/files/usr/bin/sqlcipher"
print('sqlcipher exists=', os.path.exists(sqlcipher_path))
print('sql repr=', repr(sql))

r = subprocess.run(
    [sqlcipher_path, enc],
    input=sql, capture_output=True, text=True, timeout=60
)
print('rc=', r.returncode)
print('stdout=', repr(r.stdout))
print('stderr=', repr(r.stderr))
print('plain exists=', os.path.exists(plain))
if os.path.exists(plain):
    print('plain size=', os.path.getsize(plain))