Malformed URI sequences can cause the decodeURI and decodeURIComponent functions to throw a URIError exception. This causes the entire deobfuscation attempt to fail as a result:
$ ./jstillery_cli.js obfuscated.js
URIError: URI malformed
at decodeURIComponent (<anonymous>)
at ast_reduce ([REDACTED]/src/jstiller.js:1612:45)
at ast_reduce_scoped ([REDACTED]/src/jstiller.js:840:14)
at ast_reduce ([REDACTED]/src/jstiller.js:1098:23)
at ast_reduce_scoped ([REDACTED]/src/jstiller.js:840:14)
at Array.map (<anonymous>)
at Object.ast_reduce [as deobfuscate] ([REDACTED]/src/jstiller.js:1091:26)
at Object.<anonymous> ([REDACTED]/jstillery_cli.js:61:16)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
Original:
====================
eval(String.fromCharCode(97,108,101,114,116))(1);decodeURIComponent('%xx');
====================
____________________
Deobfuscated Code
eval(String.fromCharCode(97, 108, 101, 114, 116))(1);
decodeURIComponent('%xx');
Hey @wisec,
Malformed URI sequences can cause the
decodeURI
anddecodeURIComponent
functions to throw aURIError
exception. This causes the entire deobfuscation attempt to fail as a result:The output after the fix is:
Cheers!