echo094 / decode-js

JS混淆代码的AST分析工具 AST analysis tool for obfuscated JS code
MIT License
667 stars 326 forks source link

sojsonv7: 解混淆string-array卡死 #119

Closed nongwoluanlai666 closed 1 month ago

nongwoluanlai666 commented 1 month ago

样本: https://netcut.cn/howCanIDecode

开头有个这样的特征:var _js='example.com.v2'; 有点像v7的自定义域名,但是解不出来,途中报错一个函数中的入参找不到charAt,打印了下类型是undefined and string ,然后在入参手动限制了下String,后续又有一个错误不知道怎么处理了。 日志如下,大佬得空看一下即可,不急,只是研究研究

`Debugger attached. 类型: sojsonv7 输入: input.js 输出: output.js 处理全局加密... Version var: _js Main call wrapper name: b Go to sub: aw 。。 Go to sub: cN 处理代码块加密... 处理代码块: c 不完整使用: c 0/415 。。 不完整替换: K 1/3 清理死代码... Waiting for the debugger to disconnect... D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:3278 if (!this.options.errorRecovery) throw error; ^

SyntaxError: import.meta may appear only with 'sourceType: "module"' (548:8) at constructor (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:353:19) at Parser.raise (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:3277:19) at Parser.parseImportMetaProperty (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:11108:14) at Parser.parseExprAtom (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10814:23) at Parser.parseExprSubscripts (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10590:23) at Parser.parseUpdate (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10573:21) at Parser.parseMaybeUnary (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10551:23) at Parser.parseMaybeUnaryOrPrivate (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10405:61) at Parser.parseExprOps (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10410:23) at Parser.parseMaybeConditional (D:\桌面\fun\decode-js-main\node_modules\@babel\parser\lib\index.js:10387:23) { code: 'BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED', reasonCode: 'ImportMetaOutsideModule', loc: Position { line: 548, column: 8, index: 11535 }, pos: 11535 }

Node.js v20.9.0 Waiting for the debugger to disconnect...`

echo094 commented 1 month ago

同 #121 已解决

分析已更新,见后续评论。

echo094 commented 1 month ago

https://netcut.cn/howCanIDecode2 剪切板链接被#121兄台覆盖了,烦请大佬有空的话再看下

你发个只读链接吧

nongwoluanlai666 commented 1 month ago

https://netcut.cn/p/9b853f5cf60af6ab 只读链接,感谢感谢

echo094 commented 1 month ago

你直接运行原始代码(只保留export前面的部分),一样有这个问题啊。

echo094 commented 1 month ago

这个样本做了version保护(文件被篡改了),你得把example.com.v2改回fetchv.net.v2,否则就会陷入死循环。

echo094 commented 1 month ago

另外,在解析本样本时babel会抛出BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED异常,这是因为默认配置不解析ES6的import或export语句,可通过添加{ errorRecovery: true }解决。