Skip to content

Commit f31333d

Browse files
committed
Update Frida scripts: root detection, meta hooks & h3 blocking
1 parent 49b180b commit f31333d

File tree

8 files changed

+561
-58
lines changed

8 files changed

+561
-58
lines changed

overrides/frida/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The scripts can automatically handle:
1212
* Injecting a given CA certificate into the system trust stores so they're trusted in connections by default.
1313
* Patching many (all?) known certificate pinning and certificate transparency tools, to allow interception by your CA certificate even when this is actively blocked.
1414
* On Android, as a fallback: auto-detection of remaining pinning failures, to attempt auto-patching of obfuscated certificate pinning (in fully obfuscated apps, the first request may fail, but this will trigger additional patching so that all subsequent requests work correctly).
15+
* Disabling many common root & jailbreak detections.
16+
* Blocking most HTTP/3 connections (all UDP to port 443), which may be inconvenient to intercept, ensuring apps fall back to HTTP/2 or HTTP/1.
1517

1618
## Android Getting Started Guide
1719

@@ -38,6 +40,7 @@ The scripts can automatically handle:
3840
-l ./android/android-system-certificate-injection.js \
3941
-l ./android/android-certificate-unpinning.js \
4042
-l ./android/android-certificate-unpinning-fallback.js \
43+
-l ./android/android-disable-root-detection.js \
4144
-f $PACKAGE_ID
4245
```
4346
7. Explore, examine & modify all the traffic you're interested in! If you have any problems, please [open an issue](https://github.com/httptoolkit/frida-interception-and-unpinning/issues/new) and help make these scripts even better.
@@ -61,6 +64,7 @@ The scripts can automatically handle:
6164
frida -U \
6265
-l ./config.js \
6366
-l ./ios/ios-connect-hook.js \
67+
-l ./ios/ios-disable-detection.js \
6468
-l ./native-tls-hook.js \
6569
-l ./native-connect-hook.js \
6670
-f $APP_ID
@@ -90,14 +94,15 @@ Each script includes detailed documentation on what it does and how it works in
9094
* `PROXY_HOST` - the IP address (IPv4) of the proxy server to use (not required if you're only unpinning)
9195
* `PROXY_PORT` - the port of the proxy server to use (not required if you're only unpinning)
9296
* `DEBUG_MODE` - defaults to `false`, but switching this to `true` will enable lots of extra output that can be useful for debugging and reverse engineering any issues.
97+
* `BLOCK_HTTP3` - defaults to `true`, which blocks HTTP/3 by dropping all UDP connections to port 443.
9398

9499
This should be listed on the command line before any other scripts.
95100

96101
* `native-connect-hook.js`
97102

98103
Captures all network traffic directly, routing all connections to the configured proxy host & port.
99104

100-
This is a low-level hook that applies to _all_ network connections. This ensures that all connections are forcibly redirected to the target proxy server, even those which ignore proxy settings or make other raw socket connections.
105+
This is a low-level hook that applies to _all_ network connections. This ensures that all connections are forcibly redirected to the target proxy server, even those which ignore proxy settings or make other raw socket connections, and also blocks HTTP/3 connections if enabled.
101106

102107
This hook applies to libc, and works for Android, Linux, iOS, and many other related environments.
103108

@@ -127,6 +132,14 @@ Each script includes detailed documentation on what it does and how it works in
127132

128133
Detects unhandled certificate validation failures, and attempts to handle unknown unrecognized cases with auto-generated fallback patches. This is more experimental and could be slightly unpredictable, but is very helpful for obfuscated cases, and in general will either fix pinning issues (after one initial failure) or will at least highlight code for further reverse engineering in the Frida log output. This script shares some logic with `android-certificate-unpinning.js`, and cannot be used standalone - if you want to use this script, you'll need to include the non-fallback unpinning script too.
129134
135+
* `android-disable-root-detection.js`
136+
137+
Disables common root detection checks across native and Java layers to prevent detection of rooted Android devices.
138+
139+
This script intercepts file system access, shell commands, and package lookups for known root indicators (like `su`, Magisk, and related apps), and fakes key system properties (`ro.secure`, `ro.debuggable`, etc.) to simulate a production environment.
140+
141+
It blocks suspicious behavior like file existence checks and shell command execution, helping evade detection in apps using both standard and advanced root checks.
142+
130143
* `ios/`
131144
132145
* `ios-connect-hook.js`
@@ -135,13 +148,16 @@ Each script includes detailed documentation on what it does and how it works in
135148
136149
This is a low-level hook that applies to _all_ network connections. This ensures that all connections are forcibly redirected to the target proxy server, even those which ignore proxy settings or make other raw socket connections.
137150
151+
* `ios-disable-detection.js`
152+
153+
Disables JailMonkey jailbreak detection.
154+
138155
* `utilities/test-ip-connectivity.js`
139156
140157
You probably don't want to use this normally as part of interception itself, but it can be very useful as part of your configuration setup.
141158

142159
This script allows you to configure a list of possible IP addresses and a target port, and have the process test each address, and send a message to the Frida client for the first reachable address provided. This can be useful for automated configuration processes, if you don't know which IP address is best to use to reach the proxy server (your computer) from the target device (your phone).
143160
144-
---
145161
146162
These scripts are part of [a broader HTTP Toolkit project](https://httptoolkit.com/blog/frida-mobile-interception-funding/), funded through the [NGI Zero Entrust Fund](https://nlnet.nl/entrust), established by [NLnet](https://nlnet.nl) with financial support from the European Commission's [Next Generation Internet](https://ngi.eu) program. Learn more on the [NLnet project page](https://nlnet.nl/project/F3-AppInterception#ack).
147163

overrides/frida/android/android-certificate-unpinning-fallback.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Java.perform(function () {
3838
try {
3939
const X509TrustManager = Java.use("javax.net.ssl.X509TrustManager");
4040
const defaultTrustManager = getCustomX509TrustManager(); // Defined in the unpinning script
41+
const certBytes = Java.use("java.lang.String").$new(CERT_PEM).getBytes();
42+
const trustedCACert = buildX509CertificateFromBytes(certBytes); // Ditto
4143

4244
const isX509TrustManager = (cls, methodName) =>
4345
methodName === 'checkServerTrusted' &&
@@ -78,6 +80,12 @@ Java.perform(function () {
7880
return !!matchedChain;
7981
};
8082

83+
const isMetaPinningMethod = (errorMessage, method) =>
84+
method.argumentTypes.length === 1 &&
85+
method.argumentTypes[0].className === 'java.util.List' &&
86+
method.returnType.className === 'void' &&
87+
errorMessage.includes('pinning error');
88+
8189
const matchOkHttpChain = (cls, expectedReturnTypeName) => {
8290
// Find the chain.proceed() method:
8391
const methods = getMethods(cls);
@@ -202,6 +210,23 @@ Java.perform(function () {
202210
callingClass.class.getName()
203211
}`);
204212
}
213+
} else if (isMetaPinningMethod(errorMessage, failingMethod)) {
214+
failingMethod.implementation = function (certs) {
215+
if (DEBUG_MODE) console.log(` => Fallback patch for meta proxygen pinning`);
216+
for (const cert of certs.toArray()) {
217+
if (cert.equals(trustedCACert)) {
218+
return; // Our own cert - all good
219+
}
220+
}
221+
222+
if (DEBUG_MODE) {
223+
console.warn(' Meta unpinning fallback found only untrusted certificates');
224+
}
225+
// Fall back to normal logic, in case of passthrough or similar
226+
return failingMethod.call(this, certs);
227+
}
228+
229+
console.log(` [+] ${className}->${methodName} (Meta proxygen pinning fallback patch)`);
205230
} else {
206231
console.error(' [ ] Unrecognized TLS error - this must be patched manually');
207232
return;

0 commit comments

Comments
 (0)