A CLI tool to query local WeChat data with 11 commands: sessions, history, search, contacts, members, stats, export, favorites, unread, new-messages, and init. Features: - Self-contained init with key extraction (no external deps) - On-the-fly SQLCipher decryption with caching - JSON output by default for LLM/AI tool integration - Message type filtering and chat statistics - Markdown/txt export for conversations - Cross-platform: macOS, Windows, Linux
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""密钥提取模块 — 根据平台调用对应的 scanner"""
|
||
|
||
import platform
|
||
|
||
|
||
def extract_keys(db_dir, output_path, pid=None):
|
||
"""提取微信数据库密钥并保存到 output_path。
|
||
|
||
Args:
|
||
db_dir: 微信数据库目录(db_storage)
|
||
output_path: all_keys.json 输出路径
|
||
pid: 可选,指定微信进程 PID(默认自动检测)
|
||
|
||
Returns:
|
||
dict: salt_hex -> enc_key_hex 的映射
|
||
|
||
Raises:
|
||
RuntimeError: 提取失败
|
||
"""
|
||
system = platform.system().lower()
|
||
if system == "darwin":
|
||
from .scanner_macos import extract_keys as _extract
|
||
return _extract(db_dir, output_path, pid=pid)
|
||
elif system == "windows":
|
||
from .scanner_windows import extract_keys as _extract
|
||
return _extract(db_dir, output_path, pid=pid)
|
||
elif system == "linux":
|
||
from .scanner_linux import extract_keys as _extract
|
||
return _extract(db_dir, output_path, pid=pid)
|
||
else:
|
||
raise RuntimeError(f"不支持的平台: {platform.system()}")
|