debug_shutil.py 897 Bytes
import sys, os, shutil, subprocess
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 using shutil
if os.path.exists(work_dir):
    shutil.rmtree(work_dir)
os.makedirs(work_dir, exist_ok=True)

enc = os.path.join(work_dir, 'EnMicroMsg.db')
shutil.copy(src, enc)
print('shutil.copy done, size=', os.path.getsize(enc))

plain = '/data/data/com.termux/files/home/EnMicroMsg.db.decrypted.db'
if os.path.exists(plain):
    os.remove(plain)

# Call daemon's decrypt_db
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))