Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wmpdbg(WeChat Mini Program Debugger)

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

使用

Windows

  1. 登录微信。首次安装或更新微信后,需要先打开任意小程序,确保微信已解压 flue.dll 并启动 WeChatAppEx 进程。

  2. 从当前构建版本的 flue.dll 中提取调试所需的偏移常量,并写入 config.json

    python -m configure --target windows
  3. 启动调试服务:

    python -m wmpdbg --target windows
  4. 打开或重新进入目标小程序,并按照连接 DevTools中的说明开始调试。

macOS

macOS 的 Hardened Runtime 会阻止 Frida 注入 WeChatAppEx。需要先关闭系统完整性保护(SIP),具体步骤如下:

  1. 将 Mac 关机,然后长按电源键,直到出现启动选项。
  2. 选择“选项”并点按“继续”,进入 macOS 恢复模式
  3. 在菜单栏点按“实用工具”,选择“终端”,执行 csrutil disable
  4. 重新启动 macOS。可执行 csrutil status,确认 SIP 已处于 disabled 状态。

完成准备后:

  1. 登录微信并打开任意小程序。

  2. WeChatAppEx Framework 中提取调试所需的偏移配置,并按构建版本写入 config.json

    python -m configure --target mac
  3. 启动调试服务:

    python -m wmpdbg --target mac
  4. 打开或重新进入目标小程序,并按照连接 DevTools中的说明开始调试。

不再使用本工具时,可再次进入恢复模式并执行 csrutil enable,重新启用 SIP。

Android

Android 不需要运行 configure。设备需要已获取 root 权限、已启用 USB 调试,并通过 USB 连接到运行 wmpdbg 的计算机。

  1. 确认 ADB 已识别设备,并查看设备 ABI:

    adb devices
    adb shell getprop ro.product.cpu.abi
  2. Frida 16.7.19 Release 下载与设备 ABI 对应的 frida-server。客户端依赖为 frida==16.7.19,服务端尽量使用相同版本。

    设备 ABI 下载文件
    arm64-v8a frida-server-16.7.19-android-arm64.xz
    armeabi-v7a frida-server-16.7.19-android-arm.xz
    x86_64 frida-server-16.7.19-android-x86_64.xz
    x86 frida-server-16.7.19-android-x86.xz
  3. 解压下载的 .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 &'"
  4. 启动 wmpdbg 调试服务:

    python -m wmpdbg --target android
  5. 打开目标小程序,工具会自动选择前台的 appbrand 进程。按照连接 DevTools中的说明开始调试。

连接 DevTools

启动调试服务后,在 Chromium 浏览器地址栏中打开终端输出的地址。使用默认端口时,地址为:

devtools://devtools/bundled/inspector.html?ws=127.0.0.1:62000

CLI

configure

从桌面端微信二进制文件中提取当前构建版本所需的偏移,并写入 config.json。该命令仅用于调试 Windows 或 macOS 平台的微信小程序,Android 无需执行。

python -m configure --target {mac,windows} [--binary PATH] [--build BUILD]
参数 是否必填 说明
--target 目标平台,可选值为 macwindows
--binary 手动指定二进制文件路径,默认自动探测。
--build 手动指定 WeChatAppEx/Radium 构建号,默认自动探测。

提取结果会合并到 config.jsonradium.<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

wmpdbg

启动目标平台的调试服务和本地 CDP 端点。

python -m wmpdbg --target {mac,windows,android} [--cdp-port PORT] [--process PROCESS]
参数 是否必填 说明
--target 目标平台,可选值为 macwindowsandroid
--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

参考与改进

本仓库在上述社区项目的基础上,主要做了以下改进:

  1. 多平台统一:Windows、macOS 和 Android 使用各自的调试 Provider,共用 wmpdbg CLI、本地 CDP 服务和 DevTools 入口,无需针对不同平台维护和使用多套工具。
  2. 自动提取桌面端偏移configure 模块可从桌面端微信二进制文件中自动提取 Frida 注入所需的 Hook 地址等偏移配置,不再依赖社区持续维护偏移表。
  3. 支持 Android 端小程序逻辑层调试

About

wmpdbg 是一个用于开启微信小程序逻辑层调试并将其连接到 Chrome DevTools 的命令行工具,支持 Windows、macOS 和 Android 平台的微信客户端。

Resources

Stars

26 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages