RE env for inspecting APKs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

523 lines
26 KiB

  1. /*
  2. * This script combines, fixes & extends a long list of other scripts, most notably including:
  3. *
  4. * - https://codeshare.frida.re/@akabe1/frida-multiple-unpinning/
  5. * - https://codeshare.frida.re/@avltree9798/universal-android-ssl-pinning-bypass/
  6. * - https://pastebin.com/TVJD63uM
  7. */
  8. setTimeout(function () {
  9. Java.perform(function () {
  10. console.log("---");
  11. console.log("Unpinning Android app...");
  12. /// -- Generic hook to protect against SSLPeerUnverifiedException -- ///
  13. // In some cases, with unusual cert pinning approaches, or heavy obfuscation, we can't
  14. // match the real method & package names. This is a problem! Fortunately, we can still
  15. // always match built-in types, so here we spot all failures that use the built-in cert
  16. // error type (notably this includes OkHttp), and after the first failure, we dynamically
  17. // generate & inject a patch to completely disable the method that threw the error.
  18. try {
  19. const UnverifiedCertError = Java.use('javax.net.ssl.SSLPeerUnverifiedException');
  20. UnverifiedCertError.$init.implementation = function (str) {
  21. console.log(' --> Unexpected SSL verification failure, adding dynamic patch...');
  22. try {
  23. const stackTrace = Java.use('java.lang.Thread').currentThread().getStackTrace();
  24. const exceptionStackIndex = stackTrace.findIndex(stack =>
  25. stack.getClassName() === "javax.net.ssl.SSLPeerUnverifiedException"
  26. );
  27. const callingFunctionStack = stackTrace[exceptionStackIndex + 1];
  28. const className = callingFunctionStack.getClassName();
  29. const methodName = callingFunctionStack.getMethodName();
  30. console.log(` Thrown by ${className}->${methodName}`);
  31. const callingClass = Java.use(className);
  32. const callingMethod = callingClass[methodName];
  33. if (callingMethod.implementation) return; // Already patched by Frida - skip it
  34. console.log(' Attempting to patch automatically...');
  35. const returnTypeName = callingMethod.returnType.type;
  36. callingMethod.implementation = function () {
  37. console.log(` --> Bypassing ${className}->${methodName} (automatic exception patch)`);
  38. // This is not a perfect fix! Most unknown cases like this are really just
  39. // checkCert(cert) methods though, so doing nothing is perfect, and if we
  40. // do need an actual return value then this is probably the best we can do,
  41. // and at least we're logging the method name so you can patch it manually:
  42. if (returnTypeName === 'void') {
  43. return;
  44. } else {
  45. return null;
  46. }
  47. };
  48. console.log(` [+] ${className}->${methodName} (automatic exception patch)`);
  49. } catch (e) {
  50. console.log(' [ ] Failed to automatically patch failure');
  51. }
  52. return this.$init(str);
  53. };
  54. console.log('[+] SSLPeerUnverifiedException auto-patcher');
  55. } catch (err) {
  56. console.log('[ ] SSLPeerUnverifiedException auto-patcher');
  57. }
  58. /// -- Specific targeted hooks: -- ///
  59. // HttpsURLConnection
  60. try {
  61. const HttpsURLConnection = Java.use("javax.net.ssl.HttpsURLConnection");
  62. HttpsURLConnection.setDefaultHostnameVerifier.implementation = function (hostnameVerifier) {
  63. console.log(' --> Bypassing HttpsURLConnection (setDefaultHostnameVerifier)');
  64. return; // Do nothing, i.e. don't change the hostname verifier
  65. };
  66. console.log('[+] HttpsURLConnection (setDefaultHostnameVerifier)');
  67. } catch (err) {
  68. console.log('[ ] HttpsURLConnection (setDefaultHostnameVerifier)');
  69. }
  70. try {
  71. const HttpsURLConnection = Java.use("javax.net.ssl.HttpsURLConnection");
  72. HttpsURLConnection.setSSLSocketFactory.implementation = function (SSLSocketFactory) {
  73. console.log(' --> Bypassing HttpsURLConnection (setSSLSocketFactory)');
  74. return; // Do nothing, i.e. don't change the SSL socket factory
  75. };
  76. console.log('[+] HttpsURLConnection (setSSLSocketFactory)');
  77. } catch (err) {
  78. console.log('[ ] HttpsURLConnection (setSSLSocketFactory)');
  79. }
  80. try {
  81. const HttpsURLConnection = Java.use("javax.net.ssl.HttpsURLConnection");
  82. HttpsURLConnection.setHostnameVerifier.implementation = function (hostnameVerifier) {
  83. console.log(' --> Bypassing HttpsURLConnection (setHostnameVerifier)');
  84. return; // Do nothing, i.e. don't change the hostname verifier
  85. };
  86. console.log('[+] HttpsURLConnection (setHostnameVerifier)');
  87. } catch (err) {
  88. console.log('[ ] HttpsURLConnection (setHostnameVerifier)');
  89. }
  90. // SSLContext
  91. try {
  92. const X509TrustManager = Java.use('javax.net.ssl.X509TrustManager');
  93. const SSLContext = Java.use('javax.net.ssl.SSLContext');
  94. const TrustManager = Java.registerClass({
  95. // Implement a custom TrustManager
  96. name: 'dev.asd.test.TrustManager',
  97. implements: [X509TrustManager],
  98. methods: {
  99. checkClientTrusted: function (chain, authType) { },
  100. checkServerTrusted: function (chain, authType) { },
  101. getAcceptedIssuers: function () { return []; }
  102. }
  103. });
  104. // Prepare the TrustManager array to pass to SSLContext.init()
  105. const TrustManagers = [TrustManager.$new()];
  106. // Get a handle on the init() on the SSLContext class
  107. const SSLContext_init = SSLContext.init.overload(
  108. '[Ljavax.net.ssl.KeyManager;', '[Ljavax.net.ssl.TrustManager;', 'java.security.SecureRandom'
  109. );
  110. // Override the init method, specifying the custom TrustManager
  111. SSLContext_init.implementation = function (keyManager, trustManager, secureRandom) {
  112. console.log(' --> Bypassing Trustmanager (Android < 7) request');
  113. SSLContext_init.call(this, keyManager, TrustManagers, secureRandom);
  114. };
  115. console.log('[+] SSLContext');
  116. } catch (err) {
  117. console.log('[ ] SSLContext');
  118. }
  119. // TrustManagerImpl (Android > 7)
  120. try {
  121. const array_list = Java.use("java.util.ArrayList");
  122. const TrustManagerImpl = Java.use('com.android.org.conscrypt.TrustManagerImpl');
  123. // This step is notably what defeats the most common case: network security config
  124. TrustManagerImpl.checkTrustedRecursive.implementation = function(a1, a2, a3, a4, a5, a6) {
  125. console.log(' --> Bypassing TrustManagerImpl checkTrusted ');
  126. return array_list.$new();
  127. }
  128. TrustManagerImpl.verifyChain.implementation = function (untrustedChain, trustAnchorChain, host, clientAuth, ocspData, tlsSctData) {
  129. console.log(' --> Bypassing TrustManagerImpl verifyChain: ' + host);
  130. return untrustedChain;
  131. };
  132. console.log('[+] TrustManagerImpl');
  133. } catch (err) {
  134. console.log('[ ] TrustManagerImpl');
  135. }
  136. // OkHTTPv3 (quadruple bypass)
  137. try {
  138. // Bypass OkHTTPv3 {1}
  139. const okhttp3_Activity_1 = Java.use('okhttp3.CertificatePinner');
  140. okhttp3_Activity_1.check.overload('java.lang.String', 'java.util.List').implementation = function (a, b) {
  141. console.log(' --> Bypassing OkHTTPv3 (list): ' + a);
  142. return;
  143. };
  144. console.log('[+] OkHTTPv3 (list)');
  145. } catch (err) {
  146. console.log('[ ] OkHTTPv3 (list)');
  147. }
  148. try {
  149. // Bypass OkHTTPv3 {2}
  150. // This method of CertificatePinner.check could be found in some old Android app
  151. const okhttp3_Activity_2 = Java.use('okhttp3.CertificatePinner');
  152. okhttp3_Activity_2.check.overload('java.lang.String', 'java.security.cert.Certificate').implementation = function (a, b) {
  153. console.log(' --> Bypassing OkHTTPv3 (cert): ' + a);
  154. return;
  155. };
  156. console.log('[+] OkHTTPv3 (cert)');
  157. } catch (err) {
  158. console.log('[ ] OkHTTPv3 (cert)');
  159. }
  160. try {
  161. // Bypass OkHTTPv3 {3}
  162. const okhttp3_Activity_3 = Java.use('okhttp3.CertificatePinner');
  163. okhttp3_Activity_3.check.overload('java.lang.String', '[Ljava.security.cert.Certificate;').implementation = function (a, b) {
  164. console.log(' --> Bypassing OkHTTPv3 (cert array): ' + a);
  165. return;
  166. };
  167. console.log('[+] OkHTTPv3 (cert array)');
  168. } catch (err) {
  169. console.log('[ ] OkHTTPv3 (cert array)');
  170. }
  171. try {
  172. // Bypass OkHTTPv3 {4}
  173. const okhttp3_Activity_4 = Java.use('okhttp3.CertificatePinner');
  174. okhttp3_Activity_4['check$okhttp'].implementation = function (a, b) {
  175. console.log(' --> Bypassing OkHTTPv3 ($okhttp): ' + a);
  176. return;
  177. };
  178. console.log('[+] OkHTTPv3 ($okhttp)');
  179. } catch (err) {
  180. console.log('[ ] OkHTTPv3 ($okhttp)');
  181. }
  182. // Trustkit (triple bypass)
  183. try {
  184. // Bypass Trustkit {1}
  185. const trustkit_Activity_1 = Java.use('com.datatheorem.android.trustkit.pinning.OkHostnameVerifier');
  186. trustkit_Activity_1.verify.overload('java.lang.String', 'javax.net.ssl.SSLSession').implementation = function (a, b) {
  187. console.log(' --> Bypassing Trustkit OkHostnameVerifier(SSLSession): ' + a);
  188. return true;
  189. };
  190. console.log('[+] Trustkit OkHostnameVerifier(SSLSession)');
  191. } catch (err) {
  192. console.log('[ ] Trustkit OkHostnameVerifier(SSLSession)');
  193. }
  194. try {
  195. // Bypass Trustkit {2}
  196. const trustkit_Activity_2 = Java.use('com.datatheorem.android.trustkit.pinning.OkHostnameVerifier');
  197. trustkit_Activity_2.verify.overload('java.lang.String', 'java.security.cert.X509Certificate').implementation = function (a, b) {
  198. console.log(' --> Bypassing Trustkit OkHostnameVerifier(cert): ' + a);
  199. return true;
  200. };
  201. console.log('[+] Trustkit OkHostnameVerifier(cert)');
  202. } catch (err) {
  203. console.log('[ ] Trustkit OkHostnameVerifier(cert)');
  204. }
  205. try {
  206. // Bypass Trustkit {3}
  207. const trustkit_PinningTrustManager = Java.use('com.datatheorem.android.trustkit.pinning.PinningTrustManager');
  208. trustkit_PinningTrustManager.checkServerTrusted.implementation = function () {
  209. console.log(' --> Bypassing Trustkit PinningTrustManager');
  210. };
  211. console.log('[+] Trustkit PinningTrustManager');
  212. } catch (err) {
  213. console.log('[ ] Trustkit PinningTrustManager');
  214. }
  215. // Appcelerator Titanium
  216. try {
  217. const appcelerator_PinningTrustManager = Java.use('appcelerator.https.PinningTrustManager');
  218. appcelerator_PinningTrustManager.checkServerTrusted.implementation = function () {
  219. console.log(' --> Bypassing Appcelerator PinningTrustManager');
  220. };
  221. console.log('[+] Appcelerator PinningTrustManager');
  222. } catch (err) {
  223. console.log('[ ] Appcelerator PinningTrustManager');
  224. }
  225. // OpenSSLSocketImpl Conscrypt
  226. try {
  227. const OpenSSLSocketImpl = Java.use('com.android.org.conscrypt.OpenSSLSocketImpl');
  228. OpenSSLSocketImpl.verifyCertificateChain.implementation = function (certRefs, JavaObject, authMethod) {
  229. console.log(' --> Bypassing OpenSSLSocketImpl Conscrypt');
  230. };
  231. console.log('[+] OpenSSLSocketImpl Conscrypt');
  232. } catch (err) {
  233. console.log('[ ] OpenSSLSocketImpl Conscrypt');
  234. }
  235. // OpenSSLEngineSocketImpl Conscrypt
  236. try {
  237. const OpenSSLEngineSocketImpl_Activity = Java.use('com.android.org.conscrypt.OpenSSLEngineSocketImpl');
  238. OpenSSLEngineSocketImpl_Activity.verifyCertificateChain.overload('[Ljava.lang.Long;', 'java.lang.String').implementation = function (a, b) {
  239. console.log(' --> Bypassing OpenSSLEngineSocketImpl Conscrypt: ' + b);
  240. };
  241. console.log('[+] OpenSSLEngineSocketImpl Conscrypt');
  242. } catch (err) {
  243. console.log('[ ] OpenSSLEngineSocketImpl Conscrypt');
  244. }
  245. // OpenSSLSocketImpl Apache Harmony
  246. try {
  247. const OpenSSLSocketImpl_Harmony = Java.use('org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl');
  248. OpenSSLSocketImpl_Harmony.verifyCertificateChain.implementation = function (asn1DerEncodedCertificateChain, authMethod) {
  249. console.log(' --> Bypassing OpenSSLSocketImpl Apache Harmony');
  250. };
  251. console.log('[+] OpenSSLSocketImpl Apache Harmony');
  252. } catch (err) {
  253. console.log('[ ] OpenSSLSocketImpl Apache Harmony');
  254. }
  255. // PhoneGap sslCertificateChecker (https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin)
  256. try {
  257. const phonegap_Activity = Java.use('nl.xservices.plugins.sslCertificateChecker');
  258. phonegap_Activity.execute.overload('java.lang.String', 'org.json.JSONArray', 'org.apache.cordova.CallbackContext').implementation = function (a, b, c) {
  259. console.log(' --> Bypassing PhoneGap sslCertificateChecker: ' + a);
  260. return true;
  261. };
  262. console.log('[+] PhoneGap sslCertificateChecker');
  263. } catch (err) {
  264. console.log('[ ] PhoneGap sslCertificateChecker');
  265. }
  266. // IBM MobileFirst pinTrustedCertificatePublicKey (double bypass)
  267. try {
  268. // Bypass IBM MobileFirst {1}
  269. const WLClient_Activity_1 = Java.use('com.worklight.wlclient.api.WLClient');
  270. WLClient_Activity_1.getInstance().pinTrustedCertificatePublicKey.overload('java.lang.String').implementation = function (cert) {
  271. console.log(' --> Bypassing IBM MobileFirst pinTrustedCertificatePublicKey (string): ' + cert);
  272. return;
  273. };
  274. console.log('[+] IBM MobileFirst pinTrustedCertificatePublicKey (string)');
  275. } catch (err) {
  276. console.log('[ ] IBM MobileFirst pinTrustedCertificatePublicKey (string)');
  277. }
  278. try {
  279. // Bypass IBM MobileFirst {2}
  280. const WLClient_Activity_2 = Java.use('com.worklight.wlclient.api.WLClient');
  281. WLClient_Activity_2.getInstance().pinTrustedCertificatePublicKey.overload('[Ljava.lang.String;').implementation = function (cert) {
  282. console.log(' --> Bypassing IBM MobileFirst pinTrustedCertificatePublicKey (string array): ' + cert);
  283. return;
  284. };
  285. console.log('[+] IBM MobileFirst pinTrustedCertificatePublicKey (string array)');
  286. } catch (err) {
  287. console.log('[ ] IBM MobileFirst pinTrustedCertificatePublicKey (string array)');
  288. }
  289. // IBM WorkLight (ancestor of MobileFirst) HostNameVerifierWithCertificatePinning (quadruple bypass)
  290. try {
  291. // Bypass IBM WorkLight {1}
  292. const worklight_Activity_1 = Java.use('com.worklight.wlclient.certificatepinning.HostNameVerifierWithCertificatePinning');
  293. worklight_Activity_1.verify.overload('java.lang.String', 'javax.net.ssl.SSLSocket').implementation = function (a, b) {
  294. console.log(' --> Bypassing IBM WorkLight HostNameVerifierWithCertificatePinning (SSLSocket): ' + a);
  295. return;
  296. };
  297. console.log('[+] IBM WorkLight HostNameVerifierWithCertificatePinning (SSLSocket)');
  298. } catch (err) {
  299. console.log('[ ] IBM WorkLight HostNameVerifierWithCertificatePinning (SSLSocket)');
  300. }
  301. try {
  302. // Bypass IBM WorkLight {2}
  303. const worklight_Activity_2 = Java.use('com.worklight.wlclient.certificatepinning.HostNameVerifierWithCertificatePinning');
  304. worklight_Activity_2.verify.overload('java.lang.String', 'java.security.cert.X509Certificate').implementation = function (a, b) {
  305. console.log(' --> Bypassing IBM WorkLight HostNameVerifierWithCertificatePinning (cert): ' + a);
  306. return;
  307. };
  308. console.log('[+] IBM WorkLight HostNameVerifierWithCertificatePinning (cert)');
  309. } catch (err) {
  310. console.log('[ ] IBM WorkLight HostNameVerifierWithCertificatePinning (cert)');
  311. }
  312. try {
  313. // Bypass IBM WorkLight {3}
  314. const worklight_Activity_3 = Java.use('com.worklight.wlclient.certificatepinning.HostNameVerifierWithCertificatePinning');
  315. worklight_Activity_3.verify.overload('java.lang.String', '[Ljava.lang.String;', '[Ljava.lang.String;').implementation = function (a, b) {
  316. console.log(' --> Bypassing IBM WorkLight HostNameVerifierWithCertificatePinning (string string): ' + a);
  317. return;
  318. };
  319. console.log('[+] IBM WorkLight HostNameVerifierWithCertificatePinning (string string)');
  320. } catch (err) {
  321. console.log('[ ] IBM WorkLight HostNameVerifierWithCertificatePinning (string string)');
  322. }
  323. try {
  324. // Bypass IBM WorkLight {4}
  325. const worklight_Activity_4 = Java.use('com.worklight.wlclient.certificatepinning.HostNameVerifierWithCertificatePinning');
  326. worklight_Activity_4.verify.overload('java.lang.String', 'javax.net.ssl.SSLSession').implementation = function (a, b) {
  327. console.log(' --> Bypassing IBM WorkLight HostNameVerifierWithCertificatePinning (SSLSession): ' + a);
  328. return true;
  329. };
  330. console.log('[+] IBM WorkLight HostNameVerifierWithCertificatePinning (SSLSession)');
  331. } catch (err) {
  332. console.log('[ ] IBM WorkLight HostNameVerifierWithCertificatePinning (SSLSession)');
  333. }
  334. // Conscrypt CertPinManager
  335. try {
  336. const conscrypt_CertPinManager_Activity = Java.use('com.android.org.conscrypt.CertPinManager');
  337. conscrypt_CertPinManager_Activity.isChainValid.overload('java.lang.String', 'java.util.List').implementation = function (a, b) {
  338. console.log(' --> Bypassing Conscrypt CertPinManager: ' + a);
  339. return true;
  340. };
  341. console.log('[+] Conscrypt CertPinManager');
  342. } catch (err) {
  343. console.log('[ ] Conscrypt CertPinManager');
  344. }
  345. // CWAC-Netsecurity (unofficial back-port pinner for Android<4.2) CertPinManager
  346. try {
  347. const cwac_CertPinManager_Activity = Java.use('com.commonsware.cwac.netsecurity.conscrypt.CertPinManager');
  348. cwac_CertPinManager_Activity.isChainValid.overload('java.lang.String', 'java.util.List').implementation = function (a, b) {
  349. console.log(' --> Bypassing CWAC-Netsecurity CertPinManager: ' + a);
  350. return true;
  351. };
  352. console.log('[+] CWAC-Netsecurity CertPinManager');
  353. } catch (err) {
  354. console.log('[ ] CWAC-Netsecurity CertPinManager');
  355. }
  356. // Worklight Androidgap WLCertificatePinningPlugin
  357. try {
  358. const androidgap_WLCertificatePinningPlugin_Activity = Java.use('com.worklight.androidgap.plugin.WLCertificatePinningPlugin');
  359. androidgap_WLCertificatePinningPlugin_Activity.execute.overload('java.lang.String', 'org.json.JSONArray', 'org.apache.cordova.CallbackContext').implementation = function (a, b, c) {
  360. console.log(' --> Bypassing Worklight Androidgap WLCertificatePinningPlugin: ' + a);
  361. return true;
  362. };
  363. console.log('[+] Worklight Androidgap WLCertificatePinningPlugin');
  364. } catch (err) {
  365. console.log('[ ] Worklight Androidgap WLCertificatePinningPlugin');
  366. }
  367. // Netty FingerprintTrustManagerFactory
  368. try {
  369. const netty_FingerprintTrustManagerFactory = Java.use('io.netty.handler.ssl.util.FingerprintTrustManagerFactory');
  370. netty_FingerprintTrustManagerFactory.checkTrusted.implementation = function (type, chain) {
  371. console.log(' --> Bypassing Netty FingerprintTrustManagerFactory');
  372. };
  373. console.log('[+] Netty FingerprintTrustManagerFactory');
  374. } catch (err) {
  375. console.log('[ ] Netty FingerprintTrustManagerFactory');
  376. }
  377. // Squareup CertificatePinner [OkHTTP<v3] (double bypass)
  378. try {
  379. // Bypass Squareup CertificatePinner {1}
  380. const Squareup_CertificatePinner_Activity_1 = Java.use('com.squareup.okhttp.CertificatePinner');
  381. Squareup_CertificatePinner_Activity_1.check.overload('java.lang.String', 'java.security.cert.Certificate').implementation = function (a, b) {
  382. console.log(' --> Bypassing Squareup CertificatePinner (cert): ' + a);
  383. return;
  384. };
  385. console.log('[+] Squareup CertificatePinner (cert)');
  386. } catch (err) {
  387. console.log('[ ] Squareup CertificatePinner (cert)');
  388. }
  389. try {
  390. // Bypass Squareup CertificatePinner {2}
  391. const Squareup_CertificatePinner_Activity_2 = Java.use('com.squareup.okhttp.CertificatePinner');
  392. Squareup_CertificatePinner_Activity_2.check.overload('java.lang.String', 'java.util.List').implementation = function (a, b) {
  393. console.log(' --> Bypassing Squareup CertificatePinner (list): ' + a);
  394. return;
  395. };
  396. console.log('[+] Squareup CertificatePinner (list)');
  397. } catch (err) {
  398. console.log('[ ] Squareup CertificatePinner (list)');
  399. }
  400. // Squareup OkHostnameVerifier [OkHTTP v3] (double bypass)
  401. try {
  402. // Bypass Squareup OkHostnameVerifier {1}
  403. const Squareup_OkHostnameVerifier_Activity_1 = Java.use('com.squareup.okhttp.internal.tls.OkHostnameVerifier');
  404. Squareup_OkHostnameVerifier_Activity_1.verify.overload('java.lang.String', 'java.security.cert.X509Certificate').implementation = function (a, b) {
  405. console.log(' --> Bypassing Squareup OkHostnameVerifier (cert): ' + a);
  406. return true;
  407. };
  408. console.log('[+] Squareup OkHostnameVerifier (cert)');
  409. } catch (err) {
  410. console.log('[ ] Squareup OkHostnameVerifier (cert)');
  411. }
  412. try {
  413. // Bypass Squareup OkHostnameVerifier {2}
  414. const Squareup_OkHostnameVerifier_Activity_2 = Java.use('com.squareup.okhttp.internal.tls.OkHostnameVerifier');
  415. Squareup_OkHostnameVerifier_Activity_2.verify.overload('java.lang.String', 'javax.net.ssl.SSLSession').implementation = function (a, b) {
  416. console.log(' --> Bypassing Squareup OkHostnameVerifier (SSLSession): ' + a);
  417. return true;
  418. };
  419. console.log('[+] Squareup OkHostnameVerifier (SSLSession)');
  420. } catch (err) {
  421. console.log('[ ] Squareup OkHostnameVerifier (SSLSession)');
  422. }
  423. // Android WebViewClient (double bypass)
  424. try {
  425. // Bypass WebViewClient {1} (deprecated from Android 6)
  426. const AndroidWebViewClient_Activity_1 = Java.use('android.webkit.WebViewClient');
  427. AndroidWebViewClient_Activity_1.onReceivedSslError.overload('android.webkit.WebView', 'android.webkit.SslErrorHandler', 'android.net.http.SslError').implementation = function (obj1, obj2, obj3) {
  428. console.log(' --> Bypassing Android WebViewClient (SslErrorHandler)');
  429. };
  430. console.log('[+] Android WebViewClient (SslErrorHandler)');
  431. } catch (err) {
  432. console.log('[ ] Android WebViewClient (SslErrorHandler)');
  433. }
  434. try {
  435. // Bypass WebViewClient {2}
  436. const AndroidWebViewClient_Activity_2 = Java.use('android.webkit.WebViewClient');
  437. AndroidWebViewClient_Activity_2.onReceivedSslError.overload('android.webkit.WebView', 'android.webkit.WebResourceRequest', 'android.webkit.WebResourceError').implementation = function (obj1, obj2, obj3) {
  438. console.log(' --> Bypassing Android WebViewClient (WebResourceError)');
  439. };
  440. console.log('[+] Android WebViewClient (WebResourceError)');
  441. } catch (err) {
  442. console.log('[ ] Android WebViewClient (WebResourceError)');
  443. }
  444. // Apache Cordova WebViewClient
  445. try {
  446. const CordovaWebViewClient_Activity = Java.use('org.apache.cordova.CordovaWebViewClient');
  447. CordovaWebViewClient_Activity.onReceivedSslError.overload('android.webkit.WebView', 'android.webkit.SslErrorHandler', 'android.net.http.SslError').implementation = function (obj1, obj2, obj3) {
  448. console.log(' --> Bypassing Apache Cordova WebViewClient');
  449. obj3.proceed();
  450. };
  451. } catch (err) {
  452. console.log('[ ] Apache Cordova WebViewClient');
  453. }
  454. // Boye AbstractVerifier
  455. try {
  456. const boye_AbstractVerifier = Java.use('ch.boye.httpclientandroidlib.conn.ssl.AbstractVerifier');
  457. boye_AbstractVerifier.verify.implementation = function (host, ssl) {
  458. console.log(' --> Bypassing Boye AbstractVerifier: ' + host);
  459. };
  460. } catch (err) {
  461. console.log('[ ] Boye AbstractVerifier');
  462. }
  463. // Appmattus
  464. try {
  465. const appmatus_Activity = Java.use('com.appmattus.certificatetransparency.internal.verifier.CertificateTransparencyInterceptor');
  466. appmatus_Activity['intercept'].implementation = function (a) {
  467. console.log(' --> Bypassing Appmattus (Transparency)');
  468. return a.proceed(a.request());
  469. };
  470. console.log('[+] Appmattus (Transparency)');
  471. } catch (err) {
  472. console.log('[ ] Appmattus (Transparency)');
  473. }
  474. console.log("Unpinning setup completed");
  475. console.log("---");
  476. });
  477. }, 0);