wechat_msg_crawler/wechat_cli/keys/__init__.py
canghe e64006bafe Initial release: wechat-cli v0.2.0
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
2026-04-04 11:10:10 +08:00

32 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""密钥提取模块 — 根据平台调用对应的 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()}")