From d04f0bf64ee9e9d4ac4fdd7879a2ff7cd9b5af1d Mon Sep 17 00:00:00 2001 From: j4k0xb <55899582+j4k0xb@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:32:27 +0200 Subject: [PATCH] fix: inlined control flow function that isn't called --- .../webcrack/src/deobfuscate/control-flow-object.ts | 7 +++---- .../src/deobfuscate/test/control-flow-object.test.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/webcrack/src/deobfuscate/control-flow-object.ts b/packages/webcrack/src/deobfuscate/control-flow-object.ts index fe877266..eb515313 100644 --- a/packages/webcrack/src/deobfuscate/control-flow-object.ts +++ b/packages/webcrack/src/deobfuscate/control-flow-object.ts @@ -239,11 +239,10 @@ export default { if (t.isStringLiteral(value)) { path.replaceWith(value); + } else if (path.parentPath.isCallExpression()) { + inlineFunction(value, path.parentPath); } else { - inlineFunction( - value, - path.parentPath as NodePath, - ); + path.replaceWith(value); } this.changes++; }, diff --git a/packages/webcrack/src/deobfuscate/test/control-flow-object.test.ts b/packages/webcrack/src/deobfuscate/test/control-flow-object.test.ts index f1febd20..7399384e 100644 --- a/packages/webcrack/src/deobfuscate/test/control-flow-object.test.ts +++ b/packages/webcrack/src/deobfuscate/test/control-flow-object.test.ts @@ -14,6 +14,18 @@ test('inlined object', () => { }).QuFtJ(u, undefined); `).toMatchInlineSnapshot(`u === undefined;`); + expectJS(` + a = ({ + QuFtJ: function (n, r) { + return n === r; + } + }).QuFtJ; + `).toMatchInlineSnapshot(` + a = function (n, r) { + return n === r; + }; + `); + expectJS(` ({ YhxvC: "default" }).YhxvC; `).toMatchInlineSnapshot(`"default";`);