硬核实战:深度对比网页AI与AI IDE的JS逆向分析能力
基于高度混淆的JavaScript脚本,对比网页AI与AI IDE的JS逆向分析能力
概述
在现代网络安全研究与恶意样本分析场景中,AI 早已成为常规辅助手段。
基于网络,我们可找到大量的 AI 辅助分析教程,但大部分教程都只是介绍分析用法,却鲜有对分析方法进行差异化对比的直观案例。
恰好,笔者近日遇到了一个样本,此样本是《一款伪装成豆包Claw的恶意项目》文章中的一个高度混淆的JavaScript脚本,笔者认为针对此JavaScript脚本的分析方法是一个很好的案例,因此,特此整理与大家分享。
在开始内容前,笔者先提出一个问题:当你遇到了一个高度混淆的 JavaScript 脚本时,你会采用什么方法来分析?
反正我以前的第一反应是:直接把代码复制给网页版 AI,让它帮我看看这段代码在干嘛。

实战分析1:网页版AI的挫败感
为了验证网页版AI的分析效果,笔者将原setup.js脚本上传至多个AI平台上进行分析,并输入提示词:“帮我解混淆上传的setup.js脚本,将其还原成正常易读的代码”。
通过对比各AI平台的反馈结果,笔者发现:多个网页版AI平台均无法按照笔者需求,正确的返回解混淆代码。
ChatGPT
基于ChatGPT平台,笔者发现其可按照提示词返回部分解混淆代码,但无论怎么提示,均不会返回完整的解混淆代码。
相关截图如下:


Gemini
基于Gemini平台,笔者发现其虽然可按照提示词返回完整解混淆代码,但实际对比分析,笔者却发现其返回的部分混淆代码实际是错误的。例如,Gemini平台在这里就自行构建了一个假的外联地址。
相关截图如下:


Grok
基于Grok平台,笔者发现其可按照提示词返回部分解混淆代码,但无论怎么提示,和ChatGPT平台一样,也不会返回完整的解混淆代码。例如,Grok平台在这里就未返回外联地址。
相关截图如下:


实战分析2:AI IDE的降维打击
为了验证AI IDE的分析效果,笔者将原setup.js脚本放置于Cursor中进行分析,并输入提示词:“帮我解混淆./test1/setup.js文件,还原成正常易读的代码”。
通过实操分析,笔者发现:Cursor IDE可按照笔者需求,返回解混淆代码。但实际琢磨对比,却发现其还是存在一些小瑕疵。例如,基于原setup.js脚本的解混淆,返回的解混淆代码中的URL路径不完整。
进一步对比分析,笔者发现:若人工对原setup.js脚本进行简单清洗处理,则Cursor IDE返回的解混淆代码中的URL路径即完全正确。
提供原文件
基于Cursor IDE,笔者使用了Auto模式对setup.js脚本进行解混淆,发现其可成功还原完整解混淆代码。
但结合人工验证,笔者却发现其返回的外联URL并未解密完全:
- 实际外联地址应该是:
https://trackpipe.dev/t/bootstrap?t=8d2c6bee-27ce-4943-9616-4ed17fe0fa04 - 此次分析返回的外联地址是:
https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04
相关截图如下:


提供简单处理后文件
为了解决上述问题,笔者对setup.js脚本进行了格式化处理,并对其进行了简单分析,分析发现:此脚本携带了大量的形如 _0x1084b6(0x520, 'YAdd') 结构的解密函数。
相关截图如下:

通过分析,基本确定此解密函数就是此脚本的第一层解密函数。因此,笔者尝试使用golang语言快速构建了一个解密脚本,实现对上述解密函数进行批量解密。
第一次解密函数运行后代码截图如下:

此时,对脚本再次进行分析,发现其还存在形如以下结构的解密函数。
进一步分析,发现不是很好快速构建解密脚本解密以下结构的解密函数。。。
相关代码截图如下:

基于此,笔者再次基于Cursor IDE对处理后的setup.js脚本进行解混淆,发现此次可成功还原完整解混淆代码,并提取正确的外联URL。
相关截图如下:


为什么网页版AI解混淆失败?
通过上述网页版AI与AI IDE的对比分析,我们可以直观的感受到,在面对高度混淆的大文件JS脚本时,网页版AI貌似有点拉跨。
即使网页版AI与AI IDE使用相同的AI大模型,网页版AI也无法实现类似AI IDE的解密效果。
到这里,可能很多人都会很疑惑,这究竟是为什么呢?
起初,笔者在不了解AI的情况下,也是很疑惑的,不过在查阅了相关资料和实操对比后,笔者逐渐理解了其他的奥秘:大模型本身只是一个“引擎”,而网页版 AI 和 AI IDE 是两辆装了相同引擎、但传动系统和导航配置完全不同的跑车。决定它们在混淆逆向中表现差异的,不是模型本身的智商,而是上下文的清洗、组装与传递机制。
- 上下文的“拼图”能力
- 网页版 AI 的局限: 当把一大段混淆的 JS 代码复制进网页版AI,AI 只能“就事论事”地看这段代码。由于网页版 AI 缺乏外部交叉引用的能力,当面对
_0x4a21、_0x1b3c这种毫无语义的变量及复杂控制流时,AI只能试图猜测这些变量含义,很容易在漫长的上下文里迷失,从而产生幻觉,给出错误的结论。 - AI IDE 的优势: AI IDE 拥有强大的本地文件索引能力,即使你只让它分析某一个函数,它也能自动关联、检索项目中的其他文件、依赖库、甚至是历史提交记录,能够更容易地把这些散落在各处的“解密代码”拼接起来,提供更准确的上下文。
- 产品定位
- 网页版 AI: 它是为了满足 95% 普通用户的日常需求(写邮件、查资料、做翻译、写简单脚本)而设计的。
- AI IDE: 它是为了满足“代码编写与理解”这一使用场景而设计的。它可调用LSP 语言服务、AST 抽象语法树解析、跨函数数据流追踪、控制流分析等底层能力,更机械、更严谨地去一行行推导变量的真实走向,而不是像网页版 AI 那样去“猜测”代码的大意。
- “长文本垃圾场”效应
- 网页版 AI: 当你把几万字的混淆代码灌进去时,模型会触发“长文本中间丢失”的现象,导致 AI 容易记住开头和结尾,但会忽略中间复杂的控制流跳转,导致最终得出的业务逻辑结论完全是南辕北辙。
- AI IDE: 在 IDE 内部,它会对代码进行切片和语法分析,配合编辑器的 LSP(语言服务协议),它能更精准地定位到核心的解密函数,单独复制出来让 AI 分析,避开了垃圾代码的干扰。
AI IDE分析流程拆解
为了能够更直观的感受AI IDE的解混淆流程,笔者从AI IDE中提取了AI交互内容,将其解混淆过程拆分为三部分:
- 分析setup.js脚本
- 编写反混淆脚本
- 输出setup.readable.js脚本
分析setup.js脚本
在此阶段中,AI读取并分析了setup.js脚本内容,并开始思考构建反混淆脚本。
相关截图如下:

AI交互内容如下:
#原内容
This JavaScript file is heavily obfuscated.
The obfuscation employs a string array and a decoder function with RC4-like decryption. An anti-debug loop and hex arithmetic further complicate analysis. To reverse it, a Node.js script can be written to execute the decoder functions and extract the original strings.
The author considers using an automated deobfuscator instead of manual analysis. They identify the _0x21ae function as the core decoder, taking index and key parameters, with _0x4aecec being its alias. A deobfuscation script would extract and evaluate all string references using the decoder functions. However, they note the file likely contains malware or trojan installer code.
#翻译后内容
这个 JavaScript 文件经过了高度混淆。
混淆使用了字符串数组和一个类似 RC4 解密算法的解码函数。反调试循环和十六进制运算进一步增加了分析的难度。要进行逆向工程,可以编写一个 Node.js 脚本来执行解码函数并提取原始字符串。
作者考虑使用自动反混淆器而不是手动分析。他们发现 _0x21ae 函数是核心解码器,它接受索引和密钥参数,_0x4aecec 是它的别名。反混淆脚本会提取并评估所有使用解码函数的字符串引用。然而,他们指出该文件可能包含恶意软件或木马安装程序代码。编写反混淆脚本
在此阶段中,AI构建了多个辅助解混淆的脚本(deobfuscate-setup.mjs、extract-url.mjs、deobfuscate-setup.mjs、strings-map.json),同时,配合脚本执行结果,AI还会根据执行结果不断试错,不断优化脚本。
相关截图如下:


AI交互内容1:
#原内容
The file consists of a single, extremely long line.
The file contains a single, extremely long line. A different approach is needed: execute the anti-debug IIFE first, then extract the required functions. The updated deobfuscation script should:
Run the full initialization IIFE from the start of the file
Extract _0xb077 and _0x21ae functions
Alternatively, a script can be written to execute from line 2 up to just before the async function realisticProgressBar, plus the _0x21ae function at the end.
The structure is:
Line 2: An IIFE containing array shuffling, requires, helpers, _0xb077 function, and realisticProgressBar
End of file: _0x21ae function
The _0x21ae function is defined at the end of the file but called earlier via _0x4aecec=_0x21ae, which should work because JavaScript hoists function declarations to the top of their scope. The script should execute the full initialization IIFE from the start of the file, then extract the _0xb077 and _0x21ae functions. Alternatively, a script can run from line 2 up to just before the async function realisticProgressBar, plus the _0x21ae function at the end.
#翻译后内容
该文件仅包含一行极长的代码。
该文件包含一行极长的代码。我们需要采用不同的方法:首先执行反调试的 IIFE,然后提取所需的函数。更新后的反混淆脚本应:
从文件开头运行完整的初始化 IIFE
提取 _0xb077 和 _0x21ae 函数
或者,可以编写一个脚本,从第 2 行执行到异步函数 realisticProgressBar 之前的部分,再加上末尾的 _0x21ae 函数。
结构如下:
第 2 行:包含数组重排、require、辅助函数、_0xb077 函数和 realisticProgressBar 的 IIFE
文件末尾:_0x21ae 函数
_0x21ae 函数定义在文件末尾,但通过 _0x4aecec=_0x21ae 提前调用,这应该可以正常工作,因为 JavaScript 会将函数声明提升到其作用域的顶部。脚本应从文件开头执行完整的初始化 IIFE,然后提取 _0xb077 和 _0x21ae 函数。或者,脚本可以从第 2 行运行到异步函数 realisticProgressBar 之前,并在末尾加上 _0x21ae 函数。AI交互内容2:
#原内容
The grep command found only one line since the file contains a single line.
#翻译后内容
由于该文件只有一行,因此 grep 命令只找到了一行。AI交互内容3:
#原内容
There are 1123 total calls and 1119 unique calls.
My script only decoded 21 identifiers because it was specifically matching _0x21ae and _0x4aecec. I need to modify it to match all _0x* identifiers.
I'll update the deobfuscator to:
Find all unique (hex, key) pairs regardless of function name
Decode all of them
Replace all _0xXXXX(0xYYY,'key') patterns with JSON strings
Then I'll manually create a clean setup.readable.js file based on the logic, as automated replacement on a single line might still be hard to read.
The best deliverable for the user will be setup.readable.js - a hand-restructured clean version.
#翻译后内容
总共有 1123 个调用,其中 1119 个是不同的调用。
我的脚本只解码了 21 个标识符,因为它专门匹配 _0x21ae 和 _0x4aecec。我需要修改它,使其能够匹配所有 _0x* 标识符。
我会更新反混淆器,使其:
查找所有唯一的 (十六进制,密钥) 对,无论函数名如何
解码所有这些对
将所有 _0xXXXX(0xYYY,'key') 模式替换为 JSON 字符串
然后,我会根据上述逻辑手动创建一个干净的 setup.readable.js 文件,因为单行自动替换可能仍然难以阅读。
最终交付给用户的最佳版本将是 setup.readable.js——一个手动重构的干净版本。AI交互内容4:
#原内容
The string replacement may have worked prior to the error occurring.
#翻译后内容
在错误发生之前,字符串替换可能已经成功执行。AI交互内容5:
#原内容
The deobfuscated file was not fully updated because the script failed prior to completing the write process.
The script executes in order: replace strings, then xor eval (which fails), then write file. The file likely contains only 21 strings from a previous partial run. The write operation occurs at the end, after xor eval, so it may not have executed in the latest run. To fix this, the script should write before xor eval and use the updated strings-map with 1119 entries.
#翻译后内容
由于脚本在写入过程完成之前失败,反混淆后的文件并未完全更新。
脚本按以下顺序执行:替换字符串,然后执行异或求值(失败),最后写入文件。该文件可能仅包含之前部分运行生成的 21 个字符串。写入操作发生在最后,即异或求值之后,因此在最近一次运行中可能尚未执行。为解决此问题,脚本应在异或求值之前写入文件,并使用包含 1119 个条目的更新后的字符串映射表。AI交互内容6:
#原内容
The URL https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04 suggests that the path may require a leading slash, formatted as /t/bot/{uuid}.
The URL path format requires a leading slash, specifically /t/bot/{uuid}, as indicated by the deobfuscated code showing /t/bot concatenated with the bot UUID. A clean, human-readable version named setup.readable.js needs to be created manually, incorporating imports such as fs, os, path, readline, and child_process spawn/spawnSync.
#翻译后内容
URL https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04 表明路径可能需要在前面加上斜杠,格式为 /t/bot/{uuid}。
URL 路径格式确实需要以斜杠开头,具体来说是 /t/bot/{uuid},反混淆后的代码显示 /t/bot 与机器人 UUID 连接在一起。需要手动创建一个名为 setup.readable.js 的简洁易读的版本,并导入 fs、os、path、readline 和 child_process spawn/spawnSync 等模块。AI交互内容7:
#原内容
The deobfuscation partially succeeded, decoding many strings, but the anti-debug IIFE at the start and _0x4aecec references remain.
#翻译后内容
反混淆部分成功,解码了许多字符串,但开头的反调试 IIFE 和 _0x4aecec 引用仍然存在。输出setup.readable.js脚本
在此阶段中,AI尝试将解混淆结果进行整理优化,调整相关变量名,使脚本可读、易于理解。
相关截图如下:

AI交互内容1:
#原内容
The deobfuscated file still references _0x4aecec, which was not fully removed during stripping.
I'll write setup.readable.js as a clean rewrite.
From analysis:
Entry: process.env.GHOST_PASSWORD_ONLY === '1' ? passwordOnlyMode() : main()
Utils:
delay(ms)
clear() - ANSI clear screen
green, cyan, yellow, red, bold, gray, white - ANSI colors
randomDelay(min, max)
realisticProgressBar(label) - 30 steps, width 50
logSystem(msg)
startSpinner(msg, duration)
preparePayload:
URL: https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04
HTTP GET with redirects, 30s timeout
Response JSON with p (payload base64) and k (key base64)
The decrypted payload is written to a temporary file, then executed using Node.js with specific environment variables and detached process settings. The script is unlinked after a calculated timeout of approximately 169 seconds.
For authentication verification on macOS systems, the script uses dscl . to check credentials.
The script operates in two modes: full UI installer mode and a simplified authentication-only mode. In authentication-only mode, it verifies credentials using either dscl on macOS or NetworkCredential on Windows, or su on Linux. The main mode features a fake installer UI with progress bars and system logs, polling for a payload in the background. Upon successful authentication, it executes the decrypted payload with specific environment variables and detaches the process. A timeout mechanism is implemented where the script unlinks itself after approximately 169 seconds, calculated from hexadecimal values. On macOS, it also opens the Full Disk Access settings using osascript after successful authentication.
The deobfuscated file still references _0x4aecec, which was not fully removed during stripping.
I'll write setup.readable.js as a clean rewrite.
From analysis:
Entry: process.env.GHOST_PASSWORD_ONLY === '1' ? passwordOnlyMode() : main()
Utils:
delay(ms)
clear() - ANSI clear screen
green, cyan, yellow, red, bold, gray, white - ANSI colors
randomDelay(min, max)
realisticProgressBar(label) - 30 steps, width 50
logSystem(msg)
startSpinner(msg, duration)
preparePayload:
URL: https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04
HTTP GET with redirects, 30s timeout
Response JSON with `
The user requested to restore setup.js to a readable format, so I will create setup.readable.js with the deobfuscated content. I will also overwrite setup.js with the readable version since that aligns with their intent to deobfuscate the file.
#翻译后内容
反混淆后的文件仍然引用了 _0x4aecec,这是因为在剥离过程中它没有被完全移除。
我会编写一个干净的 setup.readable.js 文件。
分析结果:
入口:process.env.GHOST_PASSWORD_ONLY === '1' ? passwordOnlyMode() : main()
Utils:
delay(ms)
clear() - ANSI 清屏
green, cyan, yellow, red, bold, gray, white - ANSI 颜色
randomDelay(min, max)
realisticProgressBar(label) - 30 步,宽度 50
logSystem(msg)
startSpinner(msg, duration)
preparePayload:
URL: https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04
HTTP GET 请求,带重定向,超时时间 30 秒
响应 JSON,包含 p(base64 编码的有效载荷)和 k(base64 编码的密钥)
解密后的有效载荷写入临时文件,然后使用 Node.js 执行,并设置特定的环境变量和分离进程。脚本在大约 169 秒的超时后断开连接。
在 macOS 系统上进行身份验证时,该脚本使用 dscl 来检查凭据。
该脚本有两种运行模式:完整的 UI 安装程序模式和简化的仅身份验证模式。在仅身份验证模式下,它使用 macOS 上的 dscl、Windows 上的 NetworkCredential 或 Linux 上的 su 来验证凭据。主模式包含一个带有进度条和系统日志的模拟安装程序 UI,并在后台轮询有效载荷。身份验证成功后,它会使用特定的环境变量执行解密的有效载荷,然后分离进程。脚本实现了一个超时机制,大约 169 秒后(根据十六进制值计算)脚本会自动解除链接。在 macOS 上,身份验证成功后,它还会使用 osascript 打开“完全磁盘访问”设置。
反混淆后的文件仍然引用了 _0x4aecec,这是因为在剥离过程中没有完全移除该引用。
我将重新编写 setup.readable.js 文件。
分析结果:
入口:process.env.GHOST_PASSWORD_ONLY === '1' ? passwordOnlyMode() : main()
工具:
delay(ms)
clear() - ANSI 清屏
green, cyan, yellow, red, bold, gray, white - ANSI 颜色
randomDelay(min, max)
realisticProgressBar(label) - 30 步,宽度 50
logSystem(msg)
startSpinner(msg, duration)
preparePayload:
URL:https://trackpipe.dev/t/bot8d2c6bee-27ce-4943-9616-4ed17fe0fa04
HTTP GET 请求,带重定向,超时时间 30 秒
响应 JSON,包含反混淆内容
用户要求将 setup.js 恢复为可读格式,因此我将创建 setup.readable.js 文件,其中包含反混淆后的内容。我还会用可读版本覆盖 setup.js 文件,因为这符合他们反混淆文件的意图。AI交互内容2:
#原内容
Let me improve the deobfuscate script to fully strip the IIFE and fix setup.deobfuscated.
#翻译后内容
让我改进反混淆脚本,使其完全剥离 IIFE 并修复 setup.deobfuscated。AI交互内容3:
#原内容
The deobfuscated JavaScript file passes syntax validation unexpectedly, even though the constant _0x4aecec was removed, as functions still reference it.
#翻译后内容
反混淆后的 JavaScript 文件意外地通过了语法验证,尽管常量 _0x4aecec 已被删除,因为函数仍然引用它。解密效果对比
虽然我们使用AI IDE成功的对setup.js脚本进行了解混淆,但毕竟我们未对其每个环节进行检查,因此,还是会对其输出结果保持怀疑态度。
那么,它实际解密效果究竟怎么样呢?
为了验证此想法,笔者尝试基于setup.js脚本进行网络调研,关联发现了伪装OpenClaw的同源攻击活动。
于是,笔者尝试将解混淆后的setup.js脚本与网络报告中的脚本功能进行详细对比,笔者发现:除部分细节代码不同外,整体代码功能及代码结构均相同。
setup.js脚本功能
- 伪装安装界面


- 窃取密码

- 外联下载payload木马


- 加载运行payload木马


网络报告中脚本功能
- 伪装安装界面

- 窃取密码

- 外联下载payload木马

- 加载运行payload木马
