fix: narrow Method 2 scan to hex charset [0-9a-f]

Previous range [a-z0-9] was too broad, matching non-hex characters
g-z which wastes CPU on false candidates. WeChat image keys are
lowercase hex strings.
feat/daemon-cli
bbingz 2026-03-05 21:53:15 +08:00 committed by ylytdeng
parent 0576151b67
commit 03582dd82c
2 changed files with 11 additions and 4 deletions

View File

@ -132,20 +132,27 @@ python find_image_key.py
#### macOS 图片解密 #### macOS 图片解密
macOS 上使用 C 版工具(通过 Mach VM API + CommonCrypto macOS 上使用 C 版工具(通过 Mach VM API + CommonCrypto性能比 Python 高 100 倍):
**前置条件:**
- Xcode Command Line Tools: `xcode-select --install`
- 微信需要 ad-hoc 签名:`sudo codesign --force --deep --sign - /Applications/WeChat.app`
- 开发者模式:系统设置 → 隐私与安全 → 开发者模式 → 开启
```bash ```bash
# 编译 # 编译
cc -O3 -o find_image_key find_image_key.c -framework Security cc -O3 -o find_image_key find_image_key.c -framework Security
cc -O3 -o decrypt_images decrypt_images.c -framework Security cc -O3 -o decrypt_images decrypt_images.c -framework Security
# 1. 持续扫描图片密钥(在微信中浏览图片触发密钥加载 # 1. 持续扫描图片密钥(在微信中浏览图片,扫描器自动捕获密钥
sudo ./find_image_key sudo ./find_image_key
# 2. 批量解密所有 V2 图片 # 2. 批量解密所有 V2 图片
./decrypt_images ./decrypt_images
``` ```
`find_image_key` 会自动发现所有未解密的 V2 图片 pattern持续扫描微信进程内存。当用户在微信中浏览图片时捕获密钥保存到 `image_keys.json`。支持 `--deep` 模式进行逐字节深度扫描。
## 文件说明 ## 文件说明
| 文件 | 说明 | | 文件 | 说明 |

View File

@ -433,12 +433,12 @@ static int scan_pid(pid_t pid) {
} }
} }
/* Method 2: ASCII [a-z0-9]{16+} at unaligned positions */ /* Method 2: hex string [0-9a-f]{16+} at unaligned positions */
int run = 0, run_start = 0; int run = 0, run_start = 0;
for (mach_msg_type_number_t j = 0; for (mach_msg_type_number_t j = 0;
j <= data_cnt && !stop_flag; j++) { j <= data_cnt && !stop_flag; j++) {
int is_hex = (j < data_cnt) && int is_hex = (j < data_cnt) &&
((buf[j]>='a' && buf[j]<='z') || ((buf[j]>='a' && buf[j]<='f') ||
(buf[j]>='0' && buf[j]<='9')); (buf[j]>='0' && buf[j]<='9'));
if (is_hex) { if (is_hex) {
if (!run) run_start = j; if (!run) run_start = j;