Instantly share code, notes, and snippets.
cubehouse/pinning.js
Last active August 6, 2026 16:56- Star 82 (82) You must be signed in to star a gist
- Fork 33 (33) You must be signed in to fork a gist
-
Select an option
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/cubehouse/56797147b5cb22768b500f25d3888a22.js"></script> - Save cubehouse/56797147b5cb22768b500f25d3888a22 to your computer and use it in GitHub Desktop.
Select an option
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/cubehouse/56797147b5cb22768b500f25d3888a22.js"></script> Save cubehouse/56797147b5cb22768b500f25d3888a22 to your computer and use it in GitHub Desktop. Download ZIP A Frida script to bypass SSL Pinning on Android. https://blog.jamie.holdings/2019/01/19/advanced-certificate-bypassing-in-android-with-frida/ Raw pinning.js 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 Show hidden characters| // start with: | |
| // frida -U -l pinning.js -f [APP_ID] --no-pause | |
| Java.perform(function () { | |
| console.log('') | |
| console.log('===') | |
| console.log('* Injecting hooks into common certificate pinning methods *') | |
| console.log('===') | |
| var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager'); | |
| var SSLContext = Java.use('javax.net.ssl.SSLContext'); | |
| // build fake trust manager | |
| var TrustManager = Java.registerClass({ | |
| name: 'com.sensepost.test.TrustManager', | |
| implements: [X509TrustManager], | |
| methods: { | |
| checkClientTrusted: function (chain, authType) { | |
| }, | |
| checkServerTrusted: function (chain, authType) { | |
| }, | |
| getAcceptedIssuers: function () { | |
| return []; | |
| } | |
| } | |
| }); | |
| // pass our own custom trust manager through when requested | |
| var TrustManagers = [TrustManager.$new()]; | |
| var SSLContext_init = SSLContext.init.overload( | |
| '[Ljavax.net.ssl.KeyManager;', '[Ljavax.net.ssl.TrustManager;', 'java.security.SecureRandom' | |
| ); | |
| SSLContext_init.implementation = function (keyManager, trustManager, secureRandom) { | |
| console.log('! Intercepted trustmanager request'); | |
| SSLContext_init.call(this, keyManager, TrustManagers, secureRandom); | |
| }; | |
| console.log('* Setup custom trust manager'); | |
| // okhttp3 | |
| try { | |
| var CertificatePinner = Java.use('okhttp3.CertificatePinner'); | |
| CertificatePinner.check.overload('java.lang.String', 'java.util.List').implementation = function (str) { | |
| console.log('! Intercepted okhttp3: ' + str); | |
| return; | |
| }; | |
| console.log('* Setup okhttp3 pinning') | |
| } catch(err) { | |
| console.log('* Unable to hook into okhttp3 pinner') | |
| } | |
| // trustkit | |
| try { | |
| var Activity = Java.use("com.datatheorem.android.trustkit.pinning.OkHostnameVerifier"); | |
| Activity.verify.overload('java.lang.String', 'javax.net.ssl.SSLSession').implementation = function (str) { | |
| console.log('! Intercepted trustkit{1}: ' + str); | |
| return true; | |
| }; | |
| Activity.verify.overload('java.lang.String', 'java.security.cert.X509Certificate').implementation = function (str) { | |
| console.log('! Intercepted trustkit{2}: ' + str); | |
| return true; | |
| }; | |
| console.log('* Setup trustkit pinning') | |
| } catch(err) { | |
| console.log('* Unable to hook into trustkit pinner') | |
| } | |
| // TrustManagerImpl | |
| try { | |
| var TrustManagerImpl = Java.use('com.android.org.conscrypt.TrustManagerImpl'); | |
| TrustManagerImpl.verifyChain.implementation = function (untrustedChain, trustAnchorChain, host, clientAuth, ocspData, tlsSctData) { | |
| console.log('! Intercepted TrustManagerImp: ' + host); | |
| return untrustedChain; | |
| } | |
| console.log('* Setup TrustManagerImpl pinning') | |
| } catch (err) { | |
| console.log('* Unable to hook into TrustManagerImpl') | |
| } | |
| // Appcelerator | |
| try { | |
| var PinningTrustManager = Java.use('appcelerator.https.PinningTrustManager'); | |
| PinningTrustManager.checkServerTrusted.implementation = function () { | |
| console.log('! Intercepted Appcelerator'); | |
| } | |
| console.log('* Setup Appcelerator pinning') | |
| } catch (err) { | |
| console.log('* Unable to hook into Appcelerator pinning') | |
| } | |
| }); |
kolsha commented Sep 6, 2019
Copy link Copy Markdownawesome!
GuilhermeCantonGB commented Nov 12, 2019
Copy link Copy Markdownawesome!
FishMan132 commented Apr 1, 2020
Copy link Copy Markdownawesome
abhay991
commented
Apr 1, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Copy link Copy MarkdownDoesn't work for kik or instagram. Any way for them?
Stucked at 'Unable to hook into Appcelerator pinning'
I will try on small apps.
ed25519pub commented May 31, 2020
Copy link Copy Markdownawesome!
MirzaHasnat commented Sep 10, 2020
Copy link Copy MarkdownUnable to hook Trust pinner error
derodevil commented Oct 3, 2020
Copy link Copy MarkdownDoesn't work for me
wanghuafeng commented Nov 27, 2020
Copy link Copy Markdownawesome!
sappi13 commented Jun 19, 2021
Copy link Copy MarkdownHi
It didn't work for me.
Spawned `com.example.mybackup`. Resuming main thread!
[Google Pixel XL::com.example.mybackup]->
===
* Injecting hooks into common certificate pinning methods *
===
* Setup custom trust manager
* Unable to hook into okhttp3 pinner
* Unable to hook into trustkit pinner
* Setup TrustManagerImpl pinning
* Unable to hook into Appcelerator pinning
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment