Root Detection Bypass

Part 5 of the Android Pentest series.

Many apps probe for root indicators at startup and refuse to run (or silently disable functionality) if they find any. To test such an app you have to make those probes lie. The frida_ssl.js script handles the common detection families.

Detection vectors and how they’re defeated

VectorWhat the app doesThe bypass
Package-basedQueries PackageManager for known root appsSpoof getPackageInfo for Magisk, SuperSU, KingoRoot, etc.
Binary-basedChecks java.io.File for su, busybox, magiskHook File.exists() to return false for those paths
Property-basedReads ro.build.selinux, ro.debuggable, ro.secureOverride SystemProperties.get() with safe values
Command executionRuns which su, id, getprop via Runtime.execRewrite root-probe commands to harmless ones
Native layerSame checks from C via libcHook fopen/system in libc.so

The key insight: Java-layer hooks won’t catch native checks and vice versa. A robust bypass covers both layers, which is why the script hooks libc.so in addition to the Java APIs.

Running it

# Spawn the target app with root bypass active
frida -U -f <package.name> -l script/frida_ssl.js

📌 Use -f (spawn), not -F (attach). Attaching to an already-running process means the root checks have likely already fired during startup. Spawning lets Frida install every hook before the app’s onCreate() runs.

A community alternative if you just need a quick check:

frida -U --codeshare dzonerzy/fridantiroot -f <package.name>

When it doesn’t work

Apps occasionally use an uncommon detection method the script doesn’t cover yet. Watch the Frida console for unhandled checks (the script logs what it intercepts), then extend the relevant hook. The most common gap is the exec-family of native calls (execl, execv, …) used to shell out to su — covered in the Tools & Scripts part, which documents the added execve/execvp coverage.

⚠️ Some apps combine root detection with SSL pinning. Bypassing root alone won’t reveal traffic — you’ll also need SSL pinning bypass.

See also

References