Android kernel root research toolkit for Honor 90 GT: SELinux device probing, slab spray primitive validation, and AArch64 kernel Image disassembly for offsets and patch checks.
This directory contains the probing and analysis tools developed in-house during the research process, all of which are independently added code and do not include the source code of any third-party project.
All C programs are cross-compiled with the same NDK command (see below), and require neither root nor an on-device compilation environment.
Requires Android NDK (this project uses r28b). Taking Windows as an example:
$NDK = "<你的NDK路径>\toolchains\llvm\prebuilt\windows-x86_64\bin"
& "$NDK\aarch64-linux-android35-clang.cmd" -O2 -static -s -o devprobe devprobe.c
adb push devprobe /data/local/tmp/
adb shell chmod 755 /data/local/tmp/devprobe
adb shell /data/local/tmp/devprobe /dev
注意:所有设备端脚本必须用 LF 换行(Windows 的 CRLF 会让
sh报错)。 转换:(Get-Content x.sh -Raw) -replace "\r`n","`n" | Set-Content -NoNewline x.sh`
devprobe.c — Enumerate /dev and test reachability from the current SELinux domainPurpose: Determine "which device nodes I can open." You must run this before attacking vendor driver vulnerabilities—if the node cannot be opened, even the best exploit is useless.
Usage:
adb shell /data/local/tmp/devprobe /dev /dev/dma_heap /dev/snd
Output: the path, type, open(O_RDWR) result, open(O_RDONLY) result, and SELinux label of each character/block device.
OK = can be opened; a number = the corresponding errno (13 = EACCES, i.e. denied by SELinux).
Read-only: it only does open followed immediately by close, with no read, no write, and no ioctl.
ashmem2_probe.c — verifying whether ashmem can be used for order-1 slab sprayingPurpose: ashmem_area_cache is order-1 (objsize 312 × 26 = 8112 ≤ 8192),
and ASHMEM_SET_NAME writes up to 248 bytes of user data into the beginning of the object.
This probe verifies: how many can be created, whether the corresponding cache in /proc/slabinfo grows, and whether the name can be read back verbatim.
⚠️ Key pitfall: on Android 16, /dev/ashmem is EACCES,
and what is actually usable is the boot-named /dev/ashmem<boot_id> (label ashmem_libcutils_device).
This tool automatically scans /dev to find the correct node.
Usage:
adb shell /data/local/tmp/ashmem2_probe 6000 240
hold_timers.c — Create N Timers and Hold ThemPurpose: When taking a snapshot of /proc/slabinfo on the host side, a stable window is needed in which "all timers are occupied."
Usage:
# 后台造 40700 个定时器并保持 25 秒
adb shell 'nohup /data/local/tmp/hold_timers 40700 25 > /tmp/hold.log 2>&1 &'
sleep 4
adb shell 'cp /proc/slabinfo /data/local/tmp/slab_during.txt'
Then compare the posix_timers_cache line with and without the allocation.
msg_spray.c — measuring how much the SysV message queue can sprayPurpose: msg_msg is the industry-standard kmalloc spray primitive. This tool tests whether it is available and how much it can spray on the target device.
(Measured locally: msgget → ENOSYS, because CONFIG_SYSVIPC is not compiled in.)
km256_probe.c / prim_probe.c — verifying controllable allocation primitives one by onePurpose: for multiple candidate primitives (setxattr / add_key / POSIX mqueue / sendmsg ancillary, etc.),
perform an actual test of "can it really allocate an object in the target cache", and report errno.
Why it matters: do not assume msg_msg will always work. Run it first, then start writing the exploit.
ipv6opt_probe.c / io_uring_probe.c — attack surface reachabilityipv6opt_probe: tests whether setsockopt(IPV6_HOPOPTS) is permitted (since 5.15 it requires CAP_NET_RAW; locally EPERM)io_uring_probe: tests whether io_uring_setup/enter/register is reachable (locally reachable)cfgcheck.sh — printing the decisive kernel configuration itemsAfter extracting /proc/config.gz, check a batch of "veto-level" configurations (USER_NS, NF_TABLES, IP_SCTP,
SYSVIPC, IO_URING, VSOCKETS, hardening options, ...).
If there is no /proc/config.gz, it can be extracted offline from the kernel Image (the Image contains IKCFG_ST / IKCFG_ED):
data = open("Image", "rb").read()
start = data.index(b"IKCFG_ST") + len(b"IKCFG_ST")
end = data.index(b"IKCFG_ED")
open("config.gz", "wb").write(data[start:end])
order1_caches.sh — List all order-1 slab cachesPurpose: When you need a spray primitive whose "allocation order matches the target," first look at what candidates are available.
awk '$6 == 2 { printf "%-32s objsize=%-6s objperslab=%-5s\n", $1, $4, $5 }' /proc/slabinfo
(/proc/slabinfo column 4 = objsize, column 5 = objperslab, column 6 = pagesperslab; 2 pages means order-1)
devlist.sh — Summarizes devprobe resultsUsed together with devprobe, it lists only the nodes that can be opened and the labels worth paying attention to.
offsets_check.py — Disassembles a specified function from the kernel ImagePurpose: Vendors do not release kernel source code, but the binary is public. This tool uses a hand-written AArch64 decoder to locate and print functions from a raw kernel Image, for:
add x11, x0, #0x7b0 ⇒ task_struct.sighand is at +0x7b0)tbz x8, #0 is there — conditional-check-style fix signatures are the cleanest)movz w1, #0x3 + bl __alloc_pages ⇒ order-3)Usage:
python offsets_check.py --all skb_page_frag_refill
python offsets_check.py --all vsock_remove_sock
Prerequisites: You need
work/Image)work/symbols_mag.json obtained by self-decoding kallsyms (format: {"imageBase": "0x...", "symbols": [{"name": ..., "address": "0x..."}, ...]})Known limitations: This is a hand-written partial decoder that only covers the subset of instructions needed for the research;
when it encounters an unrecognized instruction, it prints the machine code as-is. Bit-field extraction uses word & mask comparison (do not use word >> 26 to compare against a 10-bit pattern,
as that will fail to decode even a single instruction).
# 1. 解出内核配置,先把整片攻击面筛一遍
adb shell 'zcat /proc/config.gz' > config.txt
# 2. 看我能打开哪些设备节点
adb push devprobe /data/local/tmp/ && adb shell chmod 755 /data/local/tmp/devprobe
adb shell /data/local/tmp/devprobe /dev
# 3. 看有哪些 order-1 的缓存(找规格匹配的喷射原语)
adb push order1_caches.sh /data/local/tmp/ && adb shell sh /data/local/tmp/order1_caches.sh
# 4. 把候选原语逐个实测(别假设,跑一遍)
adb push prim_probe /data/local/tmp/ && adb shell /data/local/tmp/prim_probe 300 208
# 5. 离线查补丁:反汇编厂商内核,找修复的机器码特征
python offsets_check.py --all <目标函数>
# 6. 如果补丁在内核外(固件/闭源组件),只能真机跑官方 PoC
These tools are intended for security research and analysis of your own devices.
devprobe only opens and then closes device nodes, ashmem2_probe only creates its own memory region,
and the rest are all read-only or operate only on their own resources. Use at your own risk.