Understanding Android Hooking Frameworks
How Xposed-style frameworks and Frida change app behaviour at runtime, the artefacts they leave behind, and defensive principles for detecting them.
- #frida
- #xposed
- #lsposed
- #hooking
- #reverse engineering
Table of contents
If root is about where your app runs, hooking is about who else is running inside it. Hooking frameworks let a third party replace or wrap functions in your process — which is exactly why they're essential to security researchers and dangerous in the hands of attackers.
Two families of hooking
Managed (ART) hooking — Xposed, LSPosed
Xposed-style frameworks load early in the Android app process lifecycle (via Zygote) and patch Java/Kotlin methods in the Android Runtime. A module can run code before and after any method — changing arguments, return values or skipping it entirely.
LSPosed is the modern, Zygisk-based implementation and is widely used on rooted devices.
Dynamic instrumentation — Frida
Frida injects an agent containing a JavaScript engine into the target process. From a laptop, a researcher can enumerate classes, intercept Java methods and hook native functions live, without rebuilding anything.
Rendering diagram…
What an attacker typically targets
- Security checks — make
isRooted()returnfalse. - Certificate pinning — accept any certificate to read traffic.
- Business logic — unlock premium features, change amounts.
- Secrets in memory — dump keys or tokens after they're decrypted.
Artefacts that defenders look for
Instrumentation isn't invisible. Common, publicly documented signals include:
- Loaded libraries — unexpected
.sofiles mapped into the process. - Threads — worker threads with characteristic names.
- Listening ports and sockets — default server ports and named pipes.
- Code integrity — function prologues that no longer match what shipped.
A simple defensive check reads the process memory map for unexpected libraries:
fun suspiciousMappings(markers: List<String>): List<String> =
runCatching {
File("/proc/self/maps").readLines()
.filter { line -> markers.any { line.contains(it, ignoreCase = true) } }
.distinct()
}.getOrDefault(emptyList())Defensive principles
- Assume every client-side check can be bypassed — and design so that bypassing costs time and skill.
- Diversify — many small, independent detectors beat one clever one.
- Verify outcomes server-side — if the server re-validates the transaction, a hooked client can't forge its result.
- Harden what matters — obfuscate with R8, keep secrets off the device, and protect native code integrity.
Key takeaways
Hooking frameworks are powerful, legitimate research tools. Understanding how they work is the only way to build apps that notice them — and keep sensitive decisions somewhere they can't reach.