Skip to content

Commit

Permalink
Added two new methods to hook all things okhttp
Browse files Browse the repository at this point in the history
Added two new methods to overload for bypassing okhttp all current versions.
  • Loading branch information
StingraySA authored May 10, 2024
1 parent 6c55d7e commit 03928c9
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions agent/src/android/pinning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,56 @@ const okHttp3CertificatePinnerCheckOkHttp = (ident: string): any | undefined =>
});
};

const okHttp3CertificatePinnerExpanded = (ident: string): any | undefined => {
return wrapJavaPerform(() => {
try {
const certificatePinner: CertificatePinner = Java.use("okhttp3.CertificatePinner");
send(c.blackBright(`Found okhttp3.CertificatePinner, overriding CertificatePinner.check$okhttp()`));

try {
const CertificatePinnerCheckOkHttp = certificatePinner.check$okhttp.overload('java.lang.String', 'java.security.cert.Certificate');

// tslint:disable-next-line:only-arrow-functions
CertificatePinnerCheckOkHttp.implementation = function (str,cert) {
qsend(quiet,
c.blackBright(`[${ident}] `) + `Called check$okhttp ` +
c.green(`OkHTTP 3.x CertificatePinner.check$okhttp()`) +
str,
} catch(err) {
qsend(quiet,
c.blackBright(`[${ident}] `) +
c.red(`Skipping Expanded OkHTTP Hook`),
}

try {
const CertificatePinnerCheckOkHttp = certificatePinner.check$okhttp.overload('java.lang.String', '[Ljava.security.cert.Certificate;');

// tslint:disable-next-line:only-arrow-functions
CertificatePinnerCheckOkHttp.implementation = function (str,cert_array) {
qsend(quiet,
c.blackBright(`[${ident}] `) + `Called check$okhttp ` +
c.green(`OkHTTP 3.x CertificatePinner.check$okhttp()`) +
str,
} catch(err) {
qsend(quiet,
c.blackBright(`[${ident}] `) +
c.red(`Skipping Expanded OkHTTP Hook`),
}

);
};

return CertificatePinnerCheckOkHttp;

} catch (err) {
if ((err as Error).message.indexOf("ClassNotFoundException") === 0) {
throw err;
}
}
});
};


const appceleratorTitaniumPinningTrustManager = (ident: string): any | undefined => {
return wrapJavaPerform(() => {
try {
Expand Down

0 comments on commit 03928c9

Please sign in to comment.