Build an anti-detection rooted Android AVD — root, device identity spoofing, and proxy CA — in one command.
Features • Installation • Quick Setup & Usage • How It Works • Troubleshooting • Limitations
Most "root your emulator" guides stop at getting a # prompt. That is not the hard
part. The hard part is that a modern app inspects the device, decides it is an
emulator, and refuses to run — so you never reach the application logic you meant to
test.
This toolkit builds an AVD that gets past that: rooted with KernelSU, with a system-wide device identity that is internally consistent, and with a proxy CA installed in the trust store apps actually read on Android 14+.
Every behaviour documented here was verified on-device, not taken from vendor docs. Several findings contradict the common guides.
- One-command provisioning — build, root, grant root, spoof, install CA
- System-wide identity spoofing via a KernelSU
system.propmodule, applied atpost-fs-databefore zygote, so every app sees it from first boot - Consistent device profiles — model matched to the Android version it actually shipped with, per SDK level
- Automated root grant — no manual tapping; drives the KernelSU UI by text via
uiautomator, not fixed coordinates - Proxy CA into the APEX trust store — mounted into the zygote namespace, so it applies to every app launched afterwards
- CA survives reboot (optional) —
--persistinstalls a KernelSUservice.shmodule that re-applies the conscrypt mount on every boot. Verified end to end: after a reboot with no manual step,--statusreportedOK (2/2)and a real handshake came back signed by the proxy - Device proxy control —
proxy.shsets/clears the global HTTP proxy and auto-fills the detected proxy port (host defaults to10.0.2.2) - Burp and HTTP Toolkit auto-detection — probes listening ports and validates each one actually behaves like that proxy; any other MITM proxy (Caido, mitmproxy, ZAP, Proxyman) still works via its TLS chain
- Both CAs at once —
--proxy alltrusts Burp and HTTP Toolkit together, so switching tools is oneproxy.shcall, not a reinstall - Version guardrails — warns when the KernelSU manager drifts ahead of the kernel
- Reversible — every step has a restore/remove path
git clone https://github.com/alvinhayy/Mobile-Pentest-Setup
cd Mobile-Pentest-Setup| File | Role |
|---|---|
create-avd.sh |
build an AVD; --full runs the whole pipeline end to end |
root-avd.sh |
KernelSU kernel swap, manager install, automated root grant |
spoof-emu.sh |
system-wide device identity via a KernelSU system.prop module |
profiles.sh |
device profiles per SDK level (sourced, not run) |
mount-ca.sh |
proxy CA into the APEX trust store, via the zygote namespace |
proxy.sh |
point device traffic at a proxy |
proxies.sh |
shared proxy detection + CA retrieval (sourced by the two above) |
ui-find.py |
locates UI elements by text for the automated root grant |
CaTest.java |
TLS probe used to prove the CA is actually trusted (how) |
kernels/ |
KernelSU kernel + manager APK (details) |
proxies.sh exists so mount-ca.sh and proxy.sh can never disagree about which
proxy is running — adding support for another proxy means editing one file.
| Requirement | Notes |
|---|---|
| macOS on Apple Silicon | Scripts use BSD sed -i '' and lsof |
| Android SDK | platform-tools, emulator, cmdline-tools/latest |
| System image | system-images;android-36;google_apis_playstore;arm64-v8a (auto-installed) |
python3, openssl, curl |
No third-party Python packages |
| KernelSU kernel + manager APK | Bundled in kernels/ for API 36; other API levels need a kernel matching that image's KMI |
| Burp Suite or HTTP Toolkit | Only for TLS interception; any MITM proxy works |
Verify your environment:
sw_vers -productVersion && uname -m
adb version | head -1
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list device >/dev/null && echo "avdmanager OK"
python3 -V && openssl version && ls kernels/One command builds the lab and points it at your proxy. Pick the CA to install
with --proxy:
./create-avd.sh --name lab1 --api 36 --full # whichever proxy is up
./create-avd.sh --name lab1 --api 36 --full --proxy httptoolkit # HTTP Toolkit
./create-avd.sh --name lab1 --api 36 --full --proxy burp # Burp
./create-avd.sh --name lab1 --api 36 --full --proxy all # trust both[root] install KernelSU kernel
[boot] cold boot, wait until ready
[manager] install KernelSU Next
[grant] ROOT ACTIVE for adb shell
[spoof] SM-S921B / Android 16
[ca] HTTP Toolkit found at 127.0.0.1:8000
[ca] zygote64 + system_server + keychain + user store
[ca] persistence module installed
[proxy] device traffic → 10.0.2.2:8000
=== DONE — lab ready ===
model : SM-S921B
root : uid=0(root)
proxy : 10.0.2.2:8000
all installs both CAs, but a device can only point at one proxy — traffic goes to
whichever answers first (Burp, since 8080 is probed before 8000). Switching later
costs one command and no CA work:
./proxy.sh --connect httptoolkitStart the proxy before running the pipeline. HTTP Toolkit only opens its port while the app is running, so a CA stage that finds nothing usually just means the proxy was not up yet.
./create-avd.sh --name lab1 --api 36 # build AVD
$ANDROID_HOME/emulator/emulator -avd lab1 -no-snapshot-load
./root-avd.sh --manager kernels/KernelSU-Next-manager.apk
./root-avd.sh --grant-shell # automated, no manual taps
./spoof-emu.sh # system-wide identity
./mount-ca.sh --user --persist # proxy CA, kept across reboots
./proxy.sh --connect # route traffic to the detected proxyRunning Burp and HTTP Toolkit side by side? Trust both once, then switch freely:
./mount-ca.sh --proxy all --persist
./proxy.sh --connect httptoolkitcreate-avd.sh — build an AVD, optionally run the whole pipeline
| Flag | Description |
|---|---|
--name <name> |
AVD name |
--api <level> |
API level (default: inherited from the running AVD) |
--full |
build → root → boot → grant → spoof → CA (persistent) → proxy |
--proxy <name> |
burp, httptoolkit, or auto (default) for the CA/proxy stages |
--device, --ram, --disk |
optional; inherited from the running AVD |
--tag <tag> |
system image tag (default google_apis_playstore) |
--list, --delete <name> |
manage AVDs |
root-avd.sh — KernelSU kernel, manager, and root grant
| Flag | Description |
|---|---|
--status |
kernel state in the system image |
--install <kernel> |
install a KernelSU kernel (backs up the original once) |
--manager <apk> |
install the manager app |
--grant-shell |
grant root to adb shell automatically |
--no-update |
disable the manager's update prompt |
--pin-manager |
reinstall the archived, known-good manager |
--verify |
device state + kernel/manager version match |
--restore |
restore the original kernel |
--avd <name> |
target a specific AVD |
spoof-emu.sh — device identity
| Flag | Description |
|---|---|
| (none) | detect SDK, apply matching profile, reboot, verify |
--dry-run |
print the system.prop that would be applied |
--remove |
uninstall the module |
mount-ca.sh — proxy CA
| Flag | Description |
|---|---|
| (none) | auto-detect the running proxy, mount globally via zygote |
--ca <file> |
use an existing CA file (repeatable) |
--proxy <name> |
CA source: burp, httptoolkit, all (both), or auto (default) |
--user |
also install into the user trust store |
--app <package> |
additionally mount into one already-running app |
--all |
additionally mount into every already-running app (children of zygote) |
--persist |
also install a KernelSU module that re-applies the mount every boot |
--unpersist |
remove that persistence module |
--status |
show which processes have the CA |
proxy.sh — device HTTP proxy
| Flag | Description |
|---|---|
(none) / --status |
show the currently configured proxy |
--connect |
set proxy to 10.0.2.2 + the auto-detected proxy port |
--connect <name> |
pick the proxy by name: burp, httptoolkit, auto (all means auto here — a device points at one proxy) |
--connect <port> |
set proxy to 10.0.2.2:<port> |
--connect <host> <port> |
set an explicit host and port |
--disconnect |
clear the device proxy |
The emulator loads its kernel from kernel-ranchu inside the system image
directory. Rooting is swapping that file. Two consequences:
- Root is per system image — a brand-new AVD boots straight into the KernelSU kernel
/datais per AVD — the manager and root grant must be redone each time
Always cold boot after swapping. Loading a snapshot skips the new kernel and root appears to vanish for no visible reason.
$ adb shell su -c id
/system/bin/sh: su: inaccessible or not foundThat is not a failed root. The kernel grants root only to allowlisted UIDs, and
the allowlist is edited through the manager UI. --grant-shell drives that UI by text
via uiautomator dump — deliberately not by coordinates, which break when resolution
or app version changes.
Spoofing SM-A325F (Galaxy A32 — never went past Android 13) on an API 36 image
creates a device that cannot exist. A RASP only has to compare the model against
ro.build.version.sdk.
| SDK | Android | Model | SoC |
|---|---|---|---|
| 36 | 16 | Galaxy S24 SM-S921B |
Exynos 2400 (s5e9945) |
| 35 | 15 | Galaxy S23 SM-S911B |
Snapdragon 8 Gen 2 (kalama) |
| 34 | 14 | Galaxy S22 SM-S901B |
Snapdragon 8 Gen 1 (taro) |
| 33 | 13 | Galaxy A32 SM-A325F |
Helio G80 (mt6769) |
Add a profile by appending one case block to profiles.sh.
| Approach | Why it fails |
|---|---|
emulator -prop ro.product.model=… |
-prop cannot override ro.*; those come from build.prop and are locked by init. After boot every value reverts |
resetprop from /data/adb/ksu/bin/ |
It is a 0-byte stub on this image. Irrelevant though — ksud handles system.prop internally |
A module containing skip_mount |
Makes system.prop silently skipped, with no error at all |
| Location | Reality |
|---|---|
/data/misc/user/0/cacerts-added/ |
The "User" tab. Since Android 7 apps ignore it unless they opt in via networkSecurityConfig |
/system/etc/security/cacerts/ |
Read-only, and on Android 14+ not what Conscrypt reads — a different inode from the APEX path |
/apex/com.android.conscrypt/cacerts/ |
The one. Read-only, but can be shadowed with a tmpfs bind mount |
KernelSU/Zygisk gives each process its own mount namespace and drops module mounts
for apps, so a plain su copy is invisible to them. Mounting into init (PID 1) is not
inherited either. Mounting into zygote is — every app forked afterwards sees it.
The Settings UI is not a reliable check: it is served through KeyChain/system_server, which caches the list. Use
./mount-ca.sh --status, which looks up the exact CA hashes it installed and checks each one parses — a certificate count cannot tell a trusted CA from one the platform silently dropped.
Port numbers are never assumed. Burp defaults to 8080, HTTP Toolkit picks a free port starting at 8000 and changes it between sessions — and the same process opens ports that are not the proxy at all (Burp also listens on 9876 for MCP). So every candidate port is probed for real, and only a port that behaves like that proxy is accepted:
| Proxy | Proof it is really that proxy |
|---|---|
| Burp | http://burp/cert returns a parseable X.509 certificate |
| HTTP Toolkit | http://amiusing.httptoolkit.tech/certificate returns a PEM — over HTTP, not HTTPS, and only its own proxy answers that host |
| anything else | the port accepts a CONNECT |
The CA itself is fetched from the most reliable source available, in this order:
- A local file. HTTP Toolkit writes its CA to
ca.pemin its config directory — on macOS~/Library/Preferences/httptoolkit/ca.pem, on Linux~/.config/httptoolkit/ca.pem(envPaths('httptoolkit', { suffix: '' }).configinhttptoolkit-server). That CA is stable across sessions, so--proxy httptoolkitstill works when the app is closed — install now, start intercepting later. - The HTTP endpoint listed in the table above.
- The proxy's own TLS chain.
openssl s_client -proxy … -showcertsand take the last certificate in the chain: a MITM proxy signs per-host certificates with its CA and sends that CA as the final chain member. It is checked to be self-signed before being accepted, so a proxy that sends no chain fails loudly instead of installing a leaf certificate. This is why Caido, mitmproxy, ZAP and Proxyman work without any proxy-specific code.
When both Burp and HTTP Toolkit are running, auto takes whichever answers first —
name the one you want instead: ./mount-ca.sh --proxy httptoolkit,
./proxy.sh --connect httptoolkit.
A trust store holds many CAs, so there is no reason to choose. --proxy all
installs the Burp and HTTP Toolkit CAs in one pass; after that, switching tools
is only a matter of redirecting traffic:
./mount-ca.sh --proxy all --persist # once: both CAs, kept across reboots
./proxy.sh --connect burp # work in Burp
./proxy.sh --connect httptoolkit # switch — CA already trustedVerified on-device with both installed (151 certs = 149 baseline + 2): the same app
reached https://example.com through HTTP Toolkit (issuer=HTTP Toolkit CA) and
through Burp (issuer=PortSwigger CA) with no CA work in between. If a proxy is not
running, it is skipped with a note rather than failing the whole run.
all is meaningful only for the CA. A device points at exactly one proxy, so
proxy.sh --connect all just means "whichever is up".
A CA that installs but is silently ignored. The trust store file is PEM followed by a text dump. If the source PEM does not end in a newline, the two run together as
-----END CERTIFICATE-----Certificate:, the block never closes, and Conscrypt drops the certificate without any error — the file is present, the count goes up,--statussays installed, and every handshake still failsTrust anchor not found. HTTP Toolkit'sca.pemends exactly that way. Burp never triggers it because it serves DER and the OpenSSL conversion always terminates the line.mount-ca.shre-emits every CA through OpenSSL for this reason.
HTTP Toolkit's own "Android device via ADB" interceptor is not broken here — it reaches
root through su -c, exactly what root-avd.sh --grant-shell provides, and its
injection is close to the one in mount-ca.sh: tmpfs over the system cacerts, a bind
mount onto the APEX path, then nsenter into both zygotes and every running app.
The problem is that both write to the same two mount points, and HTTP Toolkit's script starts by unmounting them:
unmount_all /apex/com.android.conscrypt/cacerts
unmount_all /system/etc/security/cacertsSo running it discards whatever mount-ca.sh mounted, and replaces it with a mount
that does not survive a reboot. Pick one: either HTTP Toolkit's interceptor alone, or
HTTP Toolkit purely as the proxy with mount-ca.sh --persist owning the CA — which is
what --proxy httptoolkit is for.
--status verifies the CAs it installed by hash and flags any whose PEM block is
unterminated — the failure mode that makes Conscrypt drop a certificate without a word:
PROSES PID TOTAL STATUS
zygote64 468 151 OK (2/2 CA proxy)
system_server 682 151 RUSAK (1 CA tidak bisa di-parse — PEM tidak tertutup)
That catches the silent case, but only a real handshake proves the whole path. Run it from inside the mount namespace apps inherit — the shell namespace is deliberately left without the CA as a baseline.
CaTest.java is that probe — HTTPS through the proxy, printing who
signed the server certificate:
javac --release 11 CaTest.java
$ANDROID_HOME/build-tools/36.0.0/d8 --min-api 26 --output . CaTest.class
adb push classes.dex /data/local/tmp/catest.dex
ZPID=$(adb shell "su -c 'pidof zygote64'" | tr -d '\r')
adb shell "su -c 'nsenter -t $ZPID -m -- env CLASSPATH=/data/local/tmp/catest.dex \
app_process /data/local/tmp CaTest https://example.com/ 10.0.2.2 8000'"A working setup names the proxy as the issuer:
HTTP : 200
issuer : CN=HTTP Toolkit CA, O=HTTP Toolkit CA, C=XX
RESULT: TRUSTED
Run it in the shell namespace too (drop the nsenter). That one must fail with
Trust anchor for certification path not found — if it succeeds, traffic never reached
the proxy at all and the test proves nothing.
| Symptom | Cause and fix |
|---|---|
[grant] UI manager tidak kunjung siap |
The manager never opened — on a first cold boot monkey can report success while the app silently fails to start. root-avd.sh now launches the resolved launcher activity and relaunches if the process is gone, so this should self-heal; if it still trips, rerun ./root-avd.sh --grant-shell once the device is idle. |
--status reports RUSAK |
The CA file is present but its PEM block is unterminated, so Conscrypt ignores it. Reinstall — mount-ca.sh normalises every CA through OpenSSL now. Files placed by hand or by older versions are the usual source. |
| Wrong proxy picked | With both tools running, auto takes whichever answers first — in practice Burp on 8080. Name it: --proxy httptoolkit, or install both with --proxy all. |
cn_X509Util: ... Trust anchor not found in logcat |
That is Chromium, not your app — Chrome and WebView use the Chrome Root Store and ignore the system store by design. Test through a Conscrypt client instead. |
com.android.keychain shows belum |
It was forked before the mount, so it never inherited it. Only affects the Settings UI listing, not app trust. mount-ca.sh remounts it when it is running; otherwise ignore it. |
| Root gone after a restart | The snapshot was loaded instead of a cold boot, so the KernelSU kernel was skipped. Start with -no-snapshot-load. |
| CA gone after a reboot | The mount is runtime-only, so it needs the KernelSU module to be reapplied. --full installs it; a manual mount-ca.sh run does not unless you pass --persist. |
Property spoofing does not close the non-property signals:
| Path | Leak |
|---|---|
/proc/self/maps |
libEGL_emulation.so, mapper.ranchu.so, goldfish_address_space |
/proc/self/mounts |
virtio block devices |
/proc/version |
build host string |
/dev/qemu_pipe, /dev/socket/qemud |
QEMU device nodes |
| Timing checks | gettimeofday vs clock_gettime drift |
Three properties are also left untouched on purpose — ro.hardware.gralloc,
ro.hardware.vulkan, ro.boot.hardware.vulkan. The real graphics stack uses them to
select the emulation driver; changing them stops the AVD rendering. Emulator-identifying
properties still drop from 17 to 3.
Worth being honest about: against a commercial RASP this is still not enough. In one engagement the protection SDK kept reporting an emulator verdict after every path above was closed — it loads its own private copy of libc from disk and forks a watchdog process, so its checks never traverse hooks placed in the process libc. This raises the bar meaningfully against ordinary detection. It is not a guarantee of being undetectable.
CA installation is Java/Conscrypt-side only, so it covers the usual clients —
HttpURLConnection, OkHttp, Retrofit, Firebase, analytics SDKs. Two classes of client
are not covered, even though the CA is physically present in their mount namespace:
- Chrome / Chromium verify against Chrome's own bundled Chrome Root Store, not
the Android system store, so a system-installed CA is ignored. Verified on-device:
every Chrome process had the proxy CA in its
cacerts(146 vs a 145 baseline), yet the TLS handshake was still rejected withcertificate unknown. Chrome is therefore a poor interception target — test through an app that uses Conscrypt instead. - Dart/Flutter ships its own root CAs compiled into the binary and never consults the system trust store — that needs a BoringSSL patch, out of scope here.
Installing a system-trusted CA only helps against apps that rely on the default system
trust store. It does not defeat certificate pinning, where the app hardcodes a
specific certificate or public key and ignores the trust store entirely — OkHttp
CertificatePinner, TrustKit, a network_security_config <pin-set>, or a native pin.
Pinned connections still fail the TLS handshake regardless of the mounted CA. (The
"bypass SSL pinning by installing a system CA" framing common in guides is imprecise:
those apps were trusting the system store, not pinning.)
Verified on-device against a real finance app: its unpinned SDK/telemetry traffic
(Insider, Firebase Installations, Crashlytics) was intercepted cleanly through the mounted
CA, while pinned GMS/Google endpoints (app-measurement.com, *.googleapis.com) rejected
the proxy certificate at the handshake. Defeating a real pin needs a different tool —
static repackaging to strip the pin (apktool → edit network_security_config / patch the
CertificatePinner call → rebuild + re-sign), or a runtime hook — out of scope here.
The scripts in this repository are released under the MIT License.
The two binaries in kernels/ are third-party work and are not
covered by that license:
| Artifact | License | Source |
|---|---|---|
kernel-ranchu-ksu-android15-6.6 |
GPL-2.0 | Android Common Kernel common-android15-6.6 + KernelSU Next |
KernelSU-Next-manager.apk |
GPL-3.0 | KernelSU Next — unmodified upstream release |
They are redistributed with attribution and pointers to their corresponding source, as
those licenses require. See kernels/README.md for the exact build
identification and verification steps.
For use on devices and applications you own or are explicitly authorised to test. The device identity produced here is deliberately synthetic — do not use it to misrepresent a device to a service you have no authorisation to test.