Skip to content

Add Device.fix_execute_only_memory() to fix app crashes on execute-only-memory (XOM) ROMs - #156

Open
leeduin wants to merge 73 commits into
firerpa:masterfrom
leeduin:fix-xom-zygote-crash
Open

Add Device.fix_execute_only_memory() to fix app crashes on execute-only-memory (XOM) ROMs#156
leeduin wants to merge 73 commits into
firerpa:masterfrom
leeduin:fix-xom-zygote-crash

Conversation

@leeduin

@leeduin leeduin commented Sep 9, 2026

Copy link
Copy Markdown

问题

在启用 execute-only memory (XOM) 的 ROM 上(如 MIUI),lamda server 内嵌的 frida 运行时 hook zygote fork 路径后,所有 spawn / 注入的目标 app 都会在启动时崩溃:

  • 现象 1:app 卡死在启动页(splash screen)
  • 现象 2:spawn() + resume() 后进程数秒内死亡(SIGSEGV)

根因

MIUI 等 ROM 将 zygote 内的系统库映射为 --x(只执行、禁读)段。frida gum 在 zygote fork 特化路径上构建 trampoline 时需要读取目标内存(如 libmedia.so.text),触发 SEGV_ACCERR

#00 ... /system/lib64/libmedia.so (.text 段)   <- 读被 XOM 拒绝
...
<- linker64 __dl__ZN6soinfo17call_constructorsEv

zygote 内段权限被 app 继承,因此每个 fork 出的进程都会崩,与具体 app 无关。

修复

新增 Device.fix_execute_only_memory():通过 server 内嵌的 frida 运行时 attach zygote/zygote64,将后备文件位于 /system/apex/vendor 的全部 --xmprotect()r-x,fork 出的进程恢复可读,注入恢复正常。

from lamda.client import Device

d = Device("192.168.22.x")
# 设备重启 / server 重启后调用一次(XOM 是内核每次启动重新生效的)
d.fix_execute_only_memory()
# -> {'zygote64': {'fixed': 294, 'failed': 0}}

pid = d.frida.spawn(["com.example.app"])   # 之后 spawn/注入不再崩溃

实测

  • 环境:Xiaomi cepheus (MIUI V12, Android 10, arm64),lamda server 10.8
  • 修复前:注入后任意 app 卡启动页 / SIGSEGV
  • 修复后:zygote64 内 294 个 --x 系统库段恢复 r-x,目标 app(含 Unity/cocos 混合引擎、带 native 反调试的 app)正常 spawn 存活到主界面

也建议后续考虑在 server 端注入前自动执行该恢复逻辑(本 PR 先提供客户端工具方法,不改变 server 行为)。

rev1si0n and others added 29 commits May 4, 2025 08:58
Added all-llms.txt containing complete FIRERPA documentation extracted
from https://device-farm.com/doc/en/ including:

- Complete installation guide (APK, Magisk, Manual methods)
- 160+ API reference with code examples
- Built-in Frida integration and anti-detection features
- Persistent script injection and RPC capabilities
- Binary patching and debugging tools
- Network deployment (FRP, OpenVPN)
- Packet capture and security features
- Device discovery and distributed management
- OCR and image matching operations
- Interface monitoring and automation
- All commands, parameters, and technical details

This documentation is formatted for easy consumption by LLMs and AI assistants
to help developers integrate FIRERPA automation capabilities.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive English documentation for LLMs
Some OEM ROMs (e.g. MIUI) map system libraries in zygote as
execute-only memory (--x, XOM). When the frida runtime embedded in
the server hooks the zygote fork path, reading target memory to
build trampolines fails with SEGV_ACCERR, so every application
spawned/injected afterwards crashes at startup (stuck on splash
screen, or process dies right after resume()).

This adds a client-side helper that attaches to zygote (64/32-bit)
via the embedded frida runtime and mprotect()s every --x range
backed by /system, /apex or /vendor back to r-x, so processes
forked from zygote inherit readable segments again.

Usage: call once after each device/server reboot, before spawning:

    d = Device("192.168.22.0.x")
    d.fix_execute_only_memory()
    # -> {"zygote64": {"fixed": 294, "failed": 0}}

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants