debug_call.py
1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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))