wmpdbg 是一个用于开启微信小程序逻辑层调试并将其连接到 Chrome DevTools 的命令行工具,支持 Windows、macOS 和 Android 平台的微信客户端。
python -m venv .venv
source .venv/bin/activate # macOS / Linux
# .venv\Scripts\activate # Windows
python -m pip install -r requirements.txt-
登录微信。首次安装或更新微信后,需要先打开任意小程序,确保微信已解压
flue.dll并启动WeChatAppEx进程。 -
从当前构建版本的
flue.dll中提取调试所需的偏移常量,并写入config.json:python -m configure --target windows
-
启动调试服务:
python -m wmpdbg --target windows
-
打开或重新进入目标小程序,并按照连接 DevTools中的说明开始调试。
macOS 的 Hardened Runtime 会阻止 Frida 注入 WeChatAppEx。需要先关闭系统完整性保护(SIP),具体步骤如下:
- 将 Mac 关机,然后长按电源键,直到出现启动选项。
- 选择“选项”并点按“继续”,进入 macOS 恢复模式。
- 在菜单栏点按“实用工具”,选择“终端”,执行
csrutil disable。 - 重新启动 macOS。可执行
csrutil status,确认 SIP 已处于disabled状态。
完成准备后:
-
登录微信并打开任意小程序。
-
从
WeChatAppEx Framework中提取调试所需的偏移配置,并按构建版本写入config.json:python -m configure --target mac
-
启动调试服务:
python -m wmpdbg --target mac
-
打开或重新进入目标小程序,并按照连接 DevTools中的说明开始调试。
不再使用本工具时,可再次进入恢复模式并执行 csrutil enable,重新启用 SIP。
Android 不需要运行 configure。设备需要已获取 root 权限、已启用 USB 调试,并通过 USB 连接到运行 wmpdbg 的计算机。
-
确认 ADB 已识别设备,并查看设备 ABI:
adb devices adb shell getprop ro.product.cpu.abi
-
从 Frida 16.7.19 Release 下载与设备 ABI 对应的
frida-server。客户端依赖为frida==16.7.19,服务端尽量使用相同版本。设备 ABI 下载文件 arm64-v8afrida-server-16.7.19-android-arm64.xzarmeabi-v7afrida-server-16.7.19-android-arm.xzx86_64frida-server-16.7.19-android-x86_64.xzx86frida-server-16.7.19-android-x86.xz -
解压下载的
.xz文件(以arm64-v8a为例),推送到设备并以 root 权限启动:adb push frida-server-16.7.19-android-arm64 /data/local/tmp/frida-server-16.7.19 adb shell "su -c 'chmod 755 /data/local/tmp/frida-server-16.7.19'" adb shell "su -c '/data/local/tmp/frida-server-16.7.19 >/dev/null 2>&1 &'"
-
启动
wmpdbg调试服务:python -m wmpdbg --target android
-
打开目标小程序,工具会自动选择前台的
appbrand进程。按照连接 DevTools中的说明开始调试。
启动调试服务后,在 Chromium 浏览器地址栏中打开终端输出的地址。使用默认端口时,地址为:
devtools://devtools/bundled/inspector.html?ws=127.0.0.1:62000
从桌面端微信二进制文件中提取当前构建版本所需的偏移,并写入 config.json。该命令仅用于调试 Windows 或 macOS 平台的微信小程序,Android 无需执行。
python -m configure --target {mac,windows} [--binary PATH] [--build BUILD]
| 参数 | 是否必填 | 说明 |
|---|---|---|
--target |
是 | 目标平台,可选值为 mac 或 windows。 |
--binary |
否 | 手动指定二进制文件路径,默认自动探测。 |
--build |
否 | 手动指定 WeChatAppEx/Radium 构建号,默认自动探测。 |
提取结果会合并到 config.json 的 radium.<platform>.<build> 节点。一般无需手动编辑该文件;微信更新后,应重新运行对应平台的 configure 命令。
示例:
python -m configure --target mac
python -m configure --target mac --binary "/Applications/WeChat.app/Contents/MacOS/WeChatAppEx.app/Contents/Frameworks/WeChatAppEx Framework.framework/Versions/C/WeChatAppEx Framework"
python -m configure --target windows --binary "C:\Users\<username>\AppData\Roaming\Tencent\xwechat\xplugin\Plugins\RadiumWMPF\25297\extracted\runtime\flue.dll" --build 25297启动目标平台的调试服务和本地 CDP 端点。
python -m wmpdbg --target {mac,windows,android} [--cdp-port PORT] [--process PROCESS]
| 参数 | 是否必填 | 说明 |
|---|---|---|
--target |
是 | 目标平台,可选值为 mac、windows 或 android。 |
--cdp-port |
否 | 本地 CDP 端口,默认值为 62000(从 config.json 中读取)。 |
--process |
否 | 手动指定进程PID或进程名,默认自动探测。 |
示例:
python -m wmpdbg --target mac
python -m wmpdbg --target mac --cdp-port 62001
python -m wmpdbg --target windows --process 12345
python -m wmpdbg --target android --process com.tencent.mm:appbrand1本仓库在上述社区项目的基础上,主要做了以下改进:
- 多平台统一:Windows、macOS 和 Android 使用各自的调试
Provider,共用wmpdbgCLI、本地 CDP 服务和 DevTools 入口,无需针对不同平台维护和使用多套工具。 - 自动提取桌面端偏移:
configure模块可从桌面端微信二进制文件中自动提取 Frida 注入所需的 Hook 地址等偏移配置,不再依赖社区持续维护偏移表。 - 支持 Android 端小程序逻辑层调试。
