relative / synchrony

javascript-obfuscator cleaner & deobfuscator
https://deobfuscate.relative.im/
GNU General Public License v3.0
892 stars 118 forks source link

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (1:25261) #20

Closed G6KG closed 2 years ago

G6KG commented 2 years ago

trying to deobfuscate : https://github.com/asicanloveyou/RAGNAROK/blob/main/SCYLLA.js

Error :

/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:3460 var err = new SyntaxError(message); ^

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (1:25261) at Parser.pp$4.raise (/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:3460:15) at Parser.pp$8.parseStatement (/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:930:18) at Parser.pp$8.parseTopLevel (/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:813:23) at Parser.parse (/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:586:17) at Function.parse (/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:636:37) at Object.parse (/opt/homebrew/lib/node_modules/deobfuscator/node_modules/acorn/dist/acorn.js:5576:19) at ge. (/opt/homebrew/lib/node_modules/deobfuscator/dist/index.js:28:49736) at Generator.next () at /opt/homebrew/lib/node_modules/deobfuscator/dist/index.js:1:1260 at new Promise () { pos: 25261, loc: Position { line: 1, column: 25261 }, raisedAt: 25267 }

relative commented 2 years ago

apologies for late reply, this was fixed in d1fcc7ffb49d2c74a27df0e29247be9eae93ba13 but that commit has not been released to NPM yet

you must specify --sourceType module on the CLI for it to function properly

you can use the latest commit from git by doing

npm remove --global deobfuscator # or your preferred package manager
git clone https://github.com/relative/synchrony.git synchrony-git
cd synchrony-git
npm i
npm run build
npm link # or yarn link, pnpm link --global
# you'll only have to do the above steps once per pull

synchrony -v
synchrony --sourceType module -o script.cleaned.js script.js
G6KG commented 2 years ago

➜ synchrony-git git:(master) ✗ synchrony --sourceType module -o script.cleaned.js Hades1.js node:internal/process/promises:279 triggerUncaughtException(err, true / fromPromise /); ^

AssertionError [ERR_ASSERTION]: ImportDeclaration should appear when the mode is ES6 and in the module context. at Referencer.ImportDeclaration (/Users/mac/synchrony-git/node_modules/eslint-scope/dist/eslint-scope.cjs:2065:35) at Referencer.Visitor.visit (/Users/mac/synchrony-git/node_modules/esrecurse/esrecurse.js:104:34) at Referencer.Visitor.visitChildren (/Users/mac/synchrony-git/node_modules/esrecurse/esrecurse.js:83:38) at Referencer.Program (/Users/mac/synchrony-git/node_modules/eslint-scope/dist/eslint-scope.cjs:1890:14) at Referencer.Visitor.visit (/Users/mac/synchrony-git/node_modules/esrecurse/esrecurse.js:104:34) at Object.analyze (/Users/mac/synchrony-git/node_modules/eslint-scope/dist/eslint-scope.cjs:2222:16) at new oe (/Users/mac/synchrony-git/dist/index.js:28:60118) at ke. (/Users/mac/synchrony-git/dist/index.js:28:61730) at Generator.next () at /Users/mac/synchrony-git/dist/index.js:1:1267 { generatedMessage: false, code: 'ERR_ASSERTION', actual: false, expected: true, operator: '==' }

Node.js v17.8.0

relative commented 2 years ago

fixed