Skip to content

Commit

Permalink
fix: inlined control flow function that isn't called
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Jul 19, 2024
1 parent 05abe0c commit d04f0bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/webcrack/src/deobfuscate/control-flow-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<t.CallExpression>,
);
path.replaceWith(value);
}
this.changes++;
},
Expand Down
12 changes: 12 additions & 0 deletions packages/webcrack/src/deobfuscate/test/control-flow-object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";`);
Expand Down

0 comments on commit d04f0bf

Please sign in to comment.