Improve log output for easier debugging

This commit is contained in:
Tim Perry
2023-10-13 18:24:10 +02:00
parent 5e094e2e6b
commit 45c83b1499
4 changed files with 10 additions and 12 deletions
+5 -5
View File
@@ -364,7 +364,7 @@ const getJavaClassIfExists = (clsName) => {
setTimeout(function () {
Java.perform(function () {
if (DEBUG_MODE) console.debug('=== Disablig all recognized unpinning libraries ===');
if (DEBUG_MODE) console.log('\n === Disabling all recognized unpinning libraries ===');
const classesToPatch = Object.keys(PINNING_FIXES);
@@ -373,7 +373,7 @@ setTimeout(function () {
if (!TargetClass) {
// We skip patches for any classes that don't seem to be present. This is common
// as not all libraries we handle are necessarily used.
if (DEBUG_MODE) console.debug(`[ ] ${targetClassName} *`);
if (DEBUG_MODE) console.log(`[ ] ${targetClassName} *`);
return;
}
@@ -423,7 +423,7 @@ setTimeout(function () {
// happen due to methods that only appear in certain library versions or whose signatures
// have changed over time.
if (targetMethodImplementations.length === 0) {
if (DEBUG_MODE) console.debug(`[ ] ${targetClassName} ${methodDescription}`);
if (DEBUG_MODE) console.log(`[ ] ${targetClassName} ${methodDescription}`);
return;
}
@@ -435,7 +435,7 @@ setTimeout(function () {
try {
targetMethod.implementation = replacement(targetMethod);
if (DEBUG_MODE) console.debug(`[+] ${patchName}`);
if (DEBUG_MODE) console.log(`[+] ${patchName}`);
patchApplied = true;
} catch (e) {
// In theory, errors like this should never happen - it means the patch is broken
@@ -446,7 +446,7 @@ setTimeout(function () {
});
if (!patchApplied) {
console.log(`[!] Matched class ${targetClassName} but could not patch any methods`);
console.warn(`[!] Matched class ${targetClassName} but could not patch any methods`);
}
});
+2 -5
View File
@@ -46,14 +46,11 @@ setTimeout(() => {
// Replace the 'select' of every implementation, so they all send traffic to us:
proxySelectorClasses.forEach(ProxySelectorCls => {
if (DEBUG_MODE) {
console.debug('Rewriting', ProxySelectorCls.toString());
console.log('Rewriting', ProxySelectorCls.toString());
}
ProxySelectorCls.select.implementation = () => getTargetProxyList()
});
console.log(
`Rewrote ${proxySelectorClasses.length} proxy selector classes ` +
`to send traffic to ${PROXY_HOST}:${PROXY_PORT}`
);
console.log(`== Proxy configuration overridden to ${PROXY_HOST}:${PROXY_PORT} ==`);
});
});
+1 -1
View File
@@ -49,5 +49,5 @@ Java.perform(() => {
// pinning too! It auto-trusts us in any implementation that uses TrustManagerImpl (Conscrypt) as
// the underlying cert checking component.
console.log('System certificate trust injected');
console.log('== System certificate trust injected ==');
});
+2 -1
View File
@@ -25,4 +25,5 @@ const PROXY_HOST = '127.0.0.1';
const PROXY_PORT = 8000;
// Set to enable extra logging:
const DEBUG_MODE = false;
const DEBUG_MODE = false;
console.log(''); // Add a new line just for clean output & to separate reloads