ben-sb / javascript-deobfuscator

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

Replace proxy functions breaks on function that returns string literal #31

Closed leumasme closed 2 years ago

leumasme commented 2 years ago
function b() {
    return ':)';
}

b();

The above code fails to deobfuscate if the Replace Proxy Functions modification is used. Tested both via Browser and npm package - fails at

Cannot read properties of undefined (reading 'expression')
at ProxyFunction.duplicateExpression (S:\Dev\javascript-deobfuscator\dist\modifications\proxies\proxyFunction.js:89:34)
    at ProxyFunction.getReplacement (S:\Dev\javascript-deobfuscator\dist\modifications\proxies\proxyFunction.js:35:31)
    at Controller.enter (S:\Dev\javascript-deobfuscator\dist\modifications\proxies\proxyRemover.js:205:61)
    at Controller.__execute (S:\Dev\javascript-deobfuscator\node_modules\estraverse\estraverse.js:397:31)
    at Controller.traverse (S:\Dev\javascript-deobfuscator\node_modules\estraverse\estraverse.js:501:28)
    at Object.traverse (S:\Dev\javascript-deobfuscator\node_modules\estraverse\estraverse.js:713:27)
    at ProxyRemover.replaceProxyFunctionUsages (S:\Dev\javascript-deobfuscator\dist\modifications\proxies\proxyRemover.js:190:20)
    at ProxyRemover.execute (S:\Dev\javascript-deobfuscator\dist\modifications\proxies\proxyRemover.js:38:14)
    at Object.deobfuscate (S:\Dev\javascript-deobfuscator\dist\index.js:74:22)
ben-sb commented 2 years ago

Should be fixed in e4332613ac47818c6cb227ec724a316b82e5676f