ben-sb / javascript-deobfuscator

General purpose JavaScript deobfuscator
https://deobfuscate.io
Apache License 2.0
786 stars 112 forks source link

Function executor does not deal with array of literals and deletes code even if no replacement is found #33

Closed canpadawan closed 2 years ago

canpadawan commented 2 years ago

The following snippet does not simplify

function _0x1661() {
    "#execute";
    return ["str1", "str2"];
}
const foo = _0x1661()[0];

FunctionExecutor.replaceFunctionCalls() tries to replace the call by a literal value and fails (since we have a table of literals), so nothing gets replaced in the foo assigment (and cannot be simplified further).

The output is also not sound since the function is removed and the code can no longer be executed. Output is:

const foo = _0x1661()[0];

I don't know much about javascript, so there might be good reasons for not handling this. What you think?

ben-sb commented 2 years ago

Should be sorted in 7b2a9ee