Last active
June 14, 2023 16:13
-
-
Save Eltion/d915b31854fb6e740cdcd7d254b1cc81 to your computer and use it in GitHub Desktop.
Bypass SSL Pinning on Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java.perform(function () { | |
try { | |
var array_list = Java.use("java.util.ArrayList"); | |
var ApiClient = Java.use('com.android.org.conscrypt.TrustManagerImpl'); | |
if (ApiClient.checkTrustedRecursive) { | |
console.log("[*][+] Hooked checkTrustedRecursive") | |
ApiClient.checkTrustedRecursive.implementation = function (a1, a2, a3, a4, a5, a6) { | |
var k = array_list.$new(); | |
return k; | |
} | |
} else { | |
console.log("[*][-] checkTrustedRecursive not Found") | |
} | |
} catch (e) { | |
console.log("[*][-] Failed to hook checkTrustedRecursive") | |
} | |
}); | |
Java.perform(function () { | |
try { | |
const x509TrustManager = Java.use("javax.net.ssl.X509TrustManager"); | |
const sSLContext = Java.use("javax.net.ssl.SSLContext"); | |
const TrustManager = Java.registerClass({ | |
implements: [x509TrustManager], | |
methods: { | |
checkClientTrusted(chain, authType) { | |
}, | |
checkServerTrusted(chain, authType) { | |
}, | |
getAcceptedIssuers() { | |
return []; | |
}, | |
}, | |
name: "com.leftenter.elti", | |
}); | |
const TrustManagers = [TrustManager.$new()]; | |
const SSLContextInit = sSLContext.init.overload( | |
"[Ljavax.net.ssl.KeyManager;", "[Ljavax.net.ssl.TrustManager;", "java.security.SecureRandom"); | |
SSLContextInit.implementation = function (keyManager, trustManager, secureRandom) { | |
SSLContextInit.call(this, keyManager, TrustManagers, secureRandom); | |
}; | |
console.log("[*][+] Hooked SSLContextInit") | |
} catch (e) { | |
console.log("[*][-] Failed to hook SSLContextInit") | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment