debug_race.py 943 Bytes
import sys, os, shutil
sys.path.insert(0, '/data/data/com.termux/files/home/local-testkit')
import hermes_wechat_daemon as d

d.load_config()

src = d.config.get('db_src_path')
work_dir = '/data/data/com.termux/files/home/hermes_work'

# Clean and fresh copy
if os.path.exists(work_dir):
    shutil.rmtree(work_dir)
os.makedirs(work_dir, exist_ok=True)

copied = d.copy_db(src, work_dir)
print('copied=', copied)

enc = os.path.join(work_dir, 'EnMicroMsg.db')
plain = '/data/data/com.termux/files/home/EnMicroMsg.db.decrypted.db'

print('enc exists=', os.path.exists(enc))
print('enc size=', os.path.getsize(enc))

if os.path.exists(plain):
    os.remove(plain)
    print('removed old plain')

print('calling d.decrypt_db...')
ok = d.decrypt_db(enc, plain, d.config.get('sqlcipher_key'), 1024, 1)
print('decrypt ok=', ok)
print('plain exists=', os.path.exists(plain))
if os.path.exists(plain):
    print('plain size=', os.path.getsize(plain))