Skip to content

Commit ca98e91

Browse files
authored
Merge pull request #1900 from HackTricks-wiki/update_phantom-frida_20260216_130011
phantom-frida
2 parents a262b9c + c9cffcc commit ca98e91

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

src/mobile-pentesting/android-app-pentesting/android-anti-instrumentation-and-ssl-pinning-bypass.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ This page provides a practical workflow to regain dynamic analysis against Andro
1212
- Early init checks: Application.onCreate() or process start hooks that crash if instrumentation is present
1313
- TLS pinning: custom TrustManager/HostnameVerifier, OkHttp CertificatePinner, Conscrypt pinning, native pins
1414

15+
## Bypassing Anti-Frida Detection / Stealth Frida Servers
16+
17+
**phantom-frida** rebuilds Frida from source and applies ~90 patches so common Frida fingerprints disappear while the stock Frida protocol remains compatible (`frida-tools` can still connect). Target: apps that grep `/proc` (cmdline, maps, task comm, fd readlink), D-Bus service names, default ports, or exported symbols.
18+
19+
Phases:
20+
- **Source patches:** global rename of `frida` identifiers (server/agent/helper) and rebuilt helper DEX with a renamed Java package.
21+
- **Targeted build/runtime patches:** meson tweaks, memfd label changed to `jit-cache`, SELinux labels (e.g., `frida_file`) renamed, libc hooks on `exit`/`signal` disabled to avoid hook-detectors.
22+
- **Post-build rename:** exported symbol `frida_agent_main` renamed after the first compile (Vala emits it), requiring a second incremental build.
23+
- **Binary hex patches:** thread names (`gmain`, `gdbus`, `pool-spawner`) replaced; optional sweep removes leftover `frida`/`Frida` strings.
24+
25+
Detection vectors covered:
26+
- **Base (1–8):** process name `frida-server`, mapped `libfrida-agent.so`, thread names, memfd label, exported `frida_agent_main`, SELinux labels, libc hook side-effects, and D-Bus service `re.frida.server` are renamed/neutralized.
27+
- **Extended (9–16):** change listening port (`--port`), rename D-Bus interfaces/internal C symbols/GType names, temp paths like `.frida`/`frida-`, sweep binary strings, rename build-time defines and asset paths (`libdir/frida`). D-Bus interface names that are part of the wire protocol stay unchanged in base mode to avoid breaking stock clients.
28+
29+
Build/usage (Android arm64 example):
30+
```bash
31+
python3 build.py --version 17.7.2 --name myserver --port 27142 --extended --verify
32+
adb push output/myserver-server-17.7.2-android-arm64 /data/local/tmp/myserver-server
33+
adb shell chmod 755 /data/local/tmp/myserver-server
34+
adb shell /data/local/tmp/myserver-server -D &
35+
adb forward tcp:27142 tcp:27142
36+
frida -H 127.0.0.1:27142 -f com.example.app
37+
```
38+
Flags: `--skip-build` (patch only), `--skip-clone`, `--arch`, `--ndk-path`, `--temp-fixes`; WSL helper: `wsl -d Ubuntu bash build-wsl.sh`.
39+
1540
## Step 1 — Quick win: hide root with Magisk DenyList
1641

1742
- Enable Zygisk in Magisk
@@ -131,13 +156,16 @@ Java.perform(() => {
131156
});
132157
```
133158

134-
// Quick root detection stub example (adapt to target package/class names)
159+
Quick root detection stub example (adapt to target package/class names):
160+
161+
```js
135162
Java.perform(() => {
136163
try {
137164
const RootChecker = Java.use('com.target.security.RootCheck');
138165
RootChecker.isDeviceRooted.implementation = function () { return false; };
139166
} catch (e) {}
140167
});
168+
```
141169

142170
Log and neuter suspicious methods to confirm execution flow:
143171

@@ -365,6 +393,7 @@ Notes
365393
- [Magisk](https://github.com/topjohnwu/Magisk)
366394
- [Medusa (Android Frida framework)](https://github.com/Ch0pin/medusa)
367395
- [Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa](https://www.yeswehack.com/learn-bug-bounty/android-lab-mobile-hacking-tools)
396+
- [phantom-frida (stealth Frida server builder)](https://github.com/TheQmaks/phantom-frida)
368397
- [Frida OkHttp4 SSL pinning bypass script](https://github.com/Zero3141/Frida-OkHttp-Bypass)
369398
- [XDA guide to strong Play Integrity bypass (2025)](https://xdaforums.com/t/updated-11-17-2025-guide-get-strong-integrity-fix-banking-apps-revolut-google-wallet-android-16-working.4753805/)
370399

0 commit comments

Comments
 (0)