Skip to content

Commit

Permalink
fix(agent): okhttp3 sslpinning bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
eleguevel committed Nov 29, 2022
1 parent 5081750 commit 557e9fb
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions agent/src/android/pinning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,23 @@ const okHttp3CertificatePinnerCheckOkHttp = (ident: string): any | undefined =>
return wrapJavaPerform(() => {
try {
const certificatePinner: CertificatePinner = Java.use("okhttp3.CertificatePinner");
send(c.blackBright(`Found okhttp3.CertificatePinner, overriding CertificatePinner.check$okhttp()`));

const CertificatePinnerCheckOkHttp = certificatePinner.check$okhttp.overload("java.lang.String", "u15");

// tslint:disable-next-line:only-arrow-functions
CertificatePinnerCheckOkHttp.implementation = function () {
qsend(quiet,
c.blackBright(`[${ident}] `) + `Called check$okhttp ` +
c.green(`OkHTTP 3.x CertificatePinner.check$okhttp()`) +
`, not throwing an exception.`,
);
};

return CertificatePinnerCheckOkHttp;
const CertificatePinnerCheckOkHttpOverloads = [];

certificatePinner["check$okhttp"].overloads.forEach((overload) => {
// preserve the implementations so that we can create a proper job
CertificatePinnerCheckOkHttpOverloads.push(overload);

// get the argument types for this overload
const calleeArgTypes = overload.argumentTypes.map((arg) => arg.className);
send(c.blackBright(`Found okhttp3.CertificatePinner.check$okhttp(${calleeArgTypes.join(", ")}), overriding ...`));
overload.implementation = function () {
qsend(quiet, c.blackBright(`[${ident}] `) + `Called check$okhttp ` +
c.green(`OkHTTP 3.x CertificatePinner.check$okhttp()`) +
`, not throwing an exception.`);
}
});

return CertificatePinnerCheckOkHttpOverloads;

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

0 comments on commit 557e9fb

Please sign in to comment.