@@ -38,6 +38,8 @@ Java.perform(function () {
38
38
try {
39
39
const X509TrustManager = Java . use ( "javax.net.ssl.X509TrustManager" ) ;
40
40
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
41
43
42
44
const isX509TrustManager = ( cls , methodName ) =>
43
45
methodName === 'checkServerTrusted' &&
@@ -78,6 +80,12 @@ Java.perform(function () {
78
80
return ! ! matchedChain ;
79
81
} ;
80
82
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
+
81
89
const matchOkHttpChain = ( cls , expectedReturnTypeName ) => {
82
90
// Find the chain.proceed() method:
83
91
const methods = getMethods ( cls ) ;
@@ -202,6 +210,23 @@ Java.perform(function () {
202
210
callingClass . class . getName ( )
203
211
} `) ;
204
212
}
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)` ) ;
205
230
} else {
206
231
console . error ( ' [ ] Unrecognized TLS error - this must be patched manually' ) ;
207
232
return ;
0 commit comments