fix(scanner): preserve all memory keys with _by_salt fallback#83
Open
yanicklandry wants to merge 1 commit into
Open
fix(scanner): preserve all memory keys with _by_salt fallback#83yanicklandry wants to merge 1 commit into
yanicklandry wants to merge 1 commit into
Conversation
Previously, scan_keys discarded any key found in WeChat's process memory that didn't match a known DB file's salt. If DB files were inaccessible during `wx init` (permission issues, path resolution failures), zero keys were saved and decryption silently failed. Apply the same logic as khipuchat's wechat-key-extract.c: save all (key, salt) pairs found in memory unconditionally. Keys that match a DB file by salt are stored under the relative DB path as before. Keys with no match are stored under `_by_salt/<salt_hex>` so they are never lost. The daemon's DbCache::get_with_mode gains a fallback: if a DB's rel_key is not in all_keys, it reads the DB file's first 16 bytes to get the salt and retries the lookup as `_by_salt/<salt>`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c86bead to
42169de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`scan_keys` discarded any key found in WeChat's process memory that didn't match a known DB file's salt. If DB files were inaccessible during `wx init` (permission issues, path resolution failures, files not yet written), zero keys were saved and decryption silently failed with no actionable error.
Fixes #73
Solution
Save all `(key, salt)` pairs found in memory, unconditionally.
`DbCache::get_with_mode` gains a two-step key lookup:
背景 / 问题
`scan_keys` 扫描 WeChat 进程内存后,只保留能匹配到本地 DB 文件 salt 的密钥。如果 `wx init` 运行时 DB 文件不可访问(权限问题、路径未检测到等),所有候选密钥都被丢弃,导致解密静默失败,没有任何有效报错。
改动
三个平台扫描器(macOS / Linux / Windows)统一更新:无法按 salt 匹配到 DB 文件的密钥,改为以 `_by_salt/<salt_hex>` 为键保存,不再丢弃。daemon 的 `DbCache::get_with_mode` 增加回退逻辑:按相对路径找不到密钥时,读取 DB 文件头部 16 字节作为 salt,再用 `_by_salt/` 重新查找。
Validation