eBPF Engine

Kernel-level bpftrace uprobe capture with Android 10+ APEX libdexfile.so + libart.so discovery, UND/0x0 symbol filtering, per-symbol bpftrace -l verification, and safe offset fallback.

基于内核态 bpftrace uprobe 捕获 DEX 加载事件,支持 Android 10+ APEX libdexfile.so 与 libart.so 自动发现、UND/0x0 符号过滤、bpftrace -l 逐项验证与安全偏移回退。

KERNEL-LEVEL · APEX-AWARE
APEX Discovery (libdexfile.so + libart.so) → readelf FUNC Filter → bpftrace -l Verify → Safe Offset → Kernel Capture → 10-Step Repair
1. Android 10+ APEX Library Discovery /apex/com.android.art/lib64/libdexfile.so (DexFile & Loader) + libart.so (ClassLinker) 2. readelf -sW Symbol Parsing & Hygiene DexFile::DexFile (ctor) DexFileLoader::Open RegisterDexFile(s) drop UND / non-FUNC / 0x0 Strips @@VERSION suffixes → produces _SymbolInfo(library, name, offset, probe_target) 3. Per-Symbol Probeability Verification (bpftrace -l) Verifies each target library & probe before emitting script — never emits broken hooks Symbol verified → uprobe:lib:SYM Offset verified → uprobe:lib:0xOFF Unprobeable → safely omitted 4. Generate & Launch Verified bpftrace Script Push script.bt & dump_helper.sh (strict perms, shell-quoted args) → wait for "Attaching" Emits EBPF_DUMP events with pid, hex_base, and size on DEX load 5. Kernel-Space Capture & /proc/pid/mem Extraction Launch target app → kernel uprobe fires silently on ART DexFile creation Host parses EBPF_DUMP log → dump_helper.sh reads /proc/$PID/mem via dd Zero app-layer footprint · invisible to Java/native Frida detectors 6. Pull DEX Artifacts & Safe Cleanup adb pull *.dex → stop bpftrace process → remove temporary device files 7. Streaming SHA-256 Dedup + 10-Step Repair CDEX → Magic → Size → Sections → Truncation → Map → Align → Debug → NOP → SHA1/Adler32 8. Dispatcher Automatic Fallback If kernel lacks probeable uprobes, Dispatcher seamlessly falls back to Memory / Frida

APEX libdexfile.so FixAndroid 10+ APEX 适配

  • On Android 10+, DexFile & DexFileLoader live in libdexfile.so while libart.so only holds UND importsAndroid 10+ 起 DexFile 与 DexFileLoader 移至 libdexfile.so,libart.so 仅保留 UND 导入
  • Discovers both APEX libraries automatically and strips @@VERSION tags自动发现两个 APEX 库,剔除 UND/非 FUNC/0x0 并清理 @@VERSION 后缀
  • Verified by dedicated regression suite (tests/test_ebpf_engine.py)由独立回归测试集(tests/test_ebpf_engine.py)全程守护

Requirements运行前提

  • Rooted device with Linux Kernel ≥ 5.4, CONFIG_BPF, and CONFIG_UPROBES已 Root 设备,内核 ≥ 5.4 且启用 CONFIG_BPF 与 CONFIG_UPROBES
  • Static bpftrace binary pushed to /data/local/tmp/bpftrace推送静态 bpftrace 二进制至 /data/local/tmp/bpftrace
  • unpack dump app.apk -e ebpf

Practical Considerations实战注意事项

  • Stock OEM kernels (e.g., Pixel Android 13 Kernel 5.10) may restrict user-space uprobe attachment部分厂商原厂内核可能限制用户态 uprobe 挂载,此时自动降级到偏移校验或回退 Memory 引擎
  • bpftrace JIT compilation takes ~5–8s at startupbpftrace 启动编译 BPF 字节码约需 5–8 秒
  • Passive capture: combine with unpack rescan for lazy function-extracted methods被动捕获模式:对抗函数抽取壳可搭配 unpack rescan 增量触发