#!/usr/bin/env python3 import sys, os, time, hashlib, hmac, struct, subprocess sys.path.insert(0, os.path.expanduser("~/Library/Python/3.9/lib/python/site-packages")) import frida DB_BASE = os.path.expanduser( "~/Library/Containers/com.tencent.xinWeChat/Data/Documents/" "xwechat_files/yibooo_ac07/db_storage/" ) def load_header(relpath): p = os.path.join(DB_BASE, relpath) return open(p, 'rb').read(4096) if os.path.exists(p) else None def verify_raw_v4(key_hex, header): try: key = bytes.fromhex(key_hex) salt = header[:16] mac_salt = bytes(b ^ 0x3A for b in salt) hk = hashlib.pbkdf2_hmac('sha256', key, mac_salt, 2, dklen=32) h = hmac.new(hk, digestmod='sha256') h.update(header[16:4048]); h.update(header[4048:4064]); h.update(struct.pack('