Skip to content

Obfuscated js throws error: "Uncaught SyntaxError: Illegal return statement" #94

@HerrimanCoder

Description

@HerrimanCoder

I am using javascript-obfuscator 0.10.0-beta.8, and I have been obfuscating my js from the command line, with good success, for a few months now. But as of the past week or so, many of my resultant obfuscations error out inside my Chrome extension. I haven't touched javascript-obfuscator, haven't updated it, nothing. Also I haven't changed the way I'm calling it from cmd-line, nor changed any params.

Here is the error I have been getting: Uncaught SyntaxError: Illegal return statement. And here is the obfuscated block of code that triggers it:

if (_0x4423('0x7') === 'mJc') {
     zingLog(_0x4423('0x8'));
} else {
      return !![];
}

The return !![]; seems to be throwing the error. Both Chrome and JSNice point at the same line. When I encountered this 3-4 days ago, I had no idea what to do about it. I ended up re-obfuscating my files 2 or 3 more times, and after that -- PRESTO -- the error was gone. I wish I had taken a diff so I could know what changed. But that was another puzzling thing: how can I get different obfuscated results after changing nothing, no cmd-line params, no source code, etc? It seems as though the obfuscator generates different results each time it runs??

Here is how I'm calling the obfuscator:

node "C:\javascript-obfuscator.js" "myfile.js" --output "C:\obfuscated.js" --compact true --controlFlowFlattening true --controlFlowFlatteningThreshold 0.75 --deadCodeInjection true --deadCodeInjectionThreshold 0.4 --mangle false --rotateStringArray true --selfDefending true --stringArray true --stringArrayThreshold 0.75 --stringArrayEncoding false --unicodeEscapeSequence false

That always executes with no errors, and as mentioned, in the past the resulting obfuscations work great, and ran fine in Chrome. I am currently using Chrome Version 61.0.3163.79 (Official Build) (64-bit). That's the latest update as of 9/12/2017, but the previous version I was on (60.xxx - before today) threw the same error.

Is this a bug in the obfuscator? A bug in the browser? Can changing a cmd-line option solve this? My entire obfuscated file is over 1500 lines so it seems ill-advised to post all of it here, but I can if necessary. Please help.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions