# Frida WeChat Hooking Attempt (2026-06-26) ## Goal Hook WeChat's text message sending method `com.tencent.mm.ui.chatting.component.sk.p0(String, int, String)` to intercept or programmatically send messages. ## APK Analysis (Completed) ### Decompilation - **Tool**: apktool - **APK**: 261MB → decompiled 2.4GB - **Dex files**: 16 (smali ~ smali_classes16) - **Smali files**: 233,555 - **Path**: `/data/data/com.termux/files/home/wechat_decompiled/` ### Core Send Method - **Class**: `com.tencent.mm.ui.chatting.component.sk` (SendTextComponent) - **Method**: `p0(String msg, int type, String extra)` - **Return**: boolean - **Flow**: `sk.p0()` → `tk.run()` (Runnable) → `w11.s1.a()` → `w11.r1` → network send ### Why Direct API Call Fails 1. Requires full Application context (Tinker, multi-process) 2. Needs ChattingUI/Fragment lifecycle 3. Requires SQLCipher encrypted database 4. Needs network connection and authentication 5. Component system with dependency injection ## Frida Environment Setup (Completed) ### frida-server - **Version**: 17.15.3 (upgraded from 17.9.10) - **Path**: `/data/local/tmp/frida-server` - **Port**: 27042 - **Status**: Running as root daemon ### frida Python Client - **Version**: 17.15.3 - **Compiled from**: frida-core-devkit-17.15.3-android-arm64.tar.xz + meson + ninja - **Extension**: `_frida.abi3.so` (137MB) - **Installation**: `FRIDA_EXTENSION=/path/to/_frida.abi3.so pip install . --no-build-isolation` - **Verification**: `import frida; print(frida.__version__)` → `17.15.3` ### Ninja Compilation (Required for meson) PyPI ninja wheel incompatible with Android Bionic libc. Compiled from source: ```bash curl -L -o ninja-src.tar.gz https://github.com/ninja-build/ninja/archive/refs/tags/v1.12.1.tar.gz tar -xzf ninja-src.tar.gz cd ninja-1.12.1 # Patch src/util.cc: replace Bionic sysinfo branch with `return -0.0f;` python3 configure.py --bootstrap cp ninja $PREFIX/bin/ninja ``` ## Hook Attempts (Failed) ### Attempt 1: Attach to `com.tencent.mm` by name ```python device.attach('com.tencent.mm') ``` **Result**: `ProcessNotFoundError` — process name not found ### Attempt 2: Attach to `WeChat` process (pid=23178) ```python device.attach(23178) ``` **Result**: Attached successfully, but `typeof Java === 'undefined'` ### Attempt 3: Attach to `mmd` process (pid=3950) ```python device.attach(3950) ``` **Result**: Attached successfully, but `typeof Java === 'undefined'` ### Attempt 4: Spawn with `device.spawn()` ```python pid = device.spawn(['com.tencent.mm']) session = device.attach(pid) ``` **Result**: Spawned and attached, but `typeof Java === 'undefined'` ## Root Cause Analysis ### Version Mismatch (Fixed) - frida-server 17.9.10 + frida Python 17.15.3 = Java VM unavailable - **Fix**: Upgraded frida-server to 17.15.3 - **Result**: Still Java VM unavailable ### Process Model - WeChat main process appears as `mmd` or `WeChat` in frida process list, not `com.tencent.mm` - Sub-processes: `com.tencent.mm:push`, `com.tencent.mm:xweb_*` - The main process may be a native process without Java VM exposed to frida ### Android 16 Compatibility - frida-server 17.15.3 may lack Java bridge support for Android 16 - Java VM detection may require additional flags or different attach method ## Alternative Approaches ### 1. Native Hook (Interceptor.attach) Instead of `Java.perform`, use frida's native hook on JNI methods or libc functions: ```javascript Interceptor.attach(Module.findExportByName(null, "send"), { onEnter: function(args) { console.log("send() called"); } }); ``` ### 2. Xposed/LSPosed Framework - Install LSPosed module on Magisk-rooted device - Compile Xposed module (skeleton created at `/data/data/com.termux/files/home/WeChatHook/`) - **Blocker**: Termux lacks Android SDK for compilation ### 3. UI Automation (Current Working Solution) - ADBKeyboard for Chinese input - OCR for coordinate detection - Tap/swipe for UI interaction - Verified working for sending messages ## Lessons Learned 1. **frida-core-devkit version MUST match frida Python version** — check `frida-server --version` before downloading 2. **PyPI ninja wheel incompatible with Android Bionic** — must compile from source 3. **Android Bionic lacks `sysinfo`/`SI_LOAD_SHIFT`** — patch `src/util.cc` before compiling ninja 4. **frida process name may differ from package name** — enumerate all processes to find correct target 5. **Java VM availability is not guaranteed** — even with matching versions, Android 16 may block Java bridge 6. **Direct API calling is impossible** — WeChat's architecture requires full app context and lifecycle ## Files Created - `/data/data/com.termux/files/home/wechat_decompiled/` — apktool output - `/data/data/com.termux/files/home/WeChatHook/` — Xposed module skeleton - `/data/data/com.termux/files/home/frida_build/` — frida extension build directory - `/data/data/com.termux/files/home/ninja-1.12.1/` — ninja source + compiled binary ## Related References - `apktool-android-apk-decompilation.md` — APK decompilation guide - `frida-devkit-termux-compilation.md` — Frida compilation on Termux - `ninja-android-bionic-patch.md` — Ninja compilation for Android Bionic