javascript-obfuscator / javascript-obfuscator-ui

A web UI to the JavaScript Obfuscator node.js package.
https://obfuscator.io
BSD 2-Clause "Simplified" License
230 stars 130 forks source link

Error: stringArrayEncoding's elements must be unique #60

Closed communque closed 3 years ago

communque commented 3 years ago

Trying to obfuscate some code, and I got an error I haven't encountered yet: stringArrayEncoding's elements must be unique

The code was retrieved from a postgreSQL database with utf-8 encoding stored in memory.

Machine being used: CentOS Linux release 7.9.2009 (Core) require("javascript-obfuscator") returns [class s] { version: '2.10.1' }

The same JS Code obfuscated on a MacOS v11.1 where require("javascript-obfuscator") returns [class a] { version: '0.27.4' } works just fine with no errors.

What might account for this? What possible solutions?

Code and errors listed below:

JsObfOptions={
    compact: true,
    controlFlowFlattening: true,
    controlFlowFlatteningThreshold: 0.75,
    deadCodeInjection: true,
    deadCodeInjectionThreshold: 0.4,
    debugProtection: false,
    debugProtectionInterval: false,
    disableConsoleOutput: true,
    identifierNamesGenerator: 'hexadecimal',
    log: false,
    renameGlobals: false,
    rotateStringArray: true,
    selfDefending: true,
    shuffleStringArray: true,
    splitStrings: true,
    splitStringsChunkLength: 10,
    stringArray: true,
    stringArrayEncoding: 'base64',
    stringArrayThreshold: 0.75,
    transformObjectKeys: true,
    unicodeEscapeSequence: false
}

JsCodeObf=require("javascript-obfuscator").obfuscate(JsCodeClean, JsObfOptions);

//Results in the following error:
// ReferenceError: Validation failed. errors:
// 'stringArrayEncoding' errors:
//     - All stringArrayEncoding's elements must be unique
// ,    - stringArrayEncoding must be an array
// 
//     at new o (/home/node_modules/javascript-obfuscator/dist/webpack:/javascript-obfuscator/src/options/Options.ts:45:19)
//     at _createInstance (/home/node_modules/inversify/lib/resolution/instantiation.js:29:12)
//     at Object.resolveInstance (/home/node_modules/inversify/lib/resolution/instantiation.js:49:18)
//     at /home/node_modules/inversify/lib/resolution/resolver.js:73:42
//     at Array.map (<anonymous>)
//     at Object.resolveInstance (/home/node_modules/inversify/lib/resolution/instantiation.js:48:67)
//     at /home/node_modules/inversify/lib/resolution/resolver.js:73:42
//     at Array.map (<anonymous>)
//     at Object.resolveInstance (/home/node_modules/inversify/lib/resolution/instantiation.js:48:67)
//     at /home/node_modules/inversify/lib/resolution/resolver.js:73:42
communque commented 3 years ago

Resolved: In the JsObfOptions JSON, changed stringArrayEncoding to ['none', 'base64', 'rc4']

sanex3339 commented 3 years ago

Hi. Yes, stringArrayEncoding option should be an array with encodings