alangodoi/Revelio
GitHub: alangodoi/Revelio
针对 javascript-obfuscator 的 JavaScript 去混淆工具,通过沙箱执行解码器实现 RC4/Base64 编码字符串的完整恢复。
Stars: 0 | Forks: 0
# Revelio ✨
**唯一能够对 `javascript-obfuscator` 输出实现 100% 字符串恢复的去混淆工具 —— 包括 RC4 编码的字符串数组。**
大多数去混淆工具在 `stringArrayEncoding` 设置为 `rc4` 或 `base64` 时会失效,因为它们试图静态地逆向编码。Revelio 不做逆向 —— 它**在沙箱 VM 中执行原始解码器**,让混淆器自行撤销其工作。
## 处理前后对比
**处理前**
```
const _0x2e3f = _0x2011(0x1e3, 'k1@K');
if (_0x4cac(0x2a1, 'Xm#9') === _0x4cac(0x1b7, 'Pq$2')) {
_0x5fab[_0x2011(0x1f4, 'j@K1')](_0x2011(0x20c, 'Lm&8'));
}
```
**处理后**
```
const message = 'Solicitando permissao...';
if ('development' === 'production') {
console.warn('debug mode active');
}
```
## 工作原理
Revelio 的操作分为 **3 个阶段**,每个阶段建立在前一个阶段之上。
### 阶段 1 — 字符串解码
这是最难的部分。端到端处理 RC4 和 base64 字符串数组编码:
1. 检测字符串数组(`_0x1e6a`、`_0x4cac` 等)及其旋转 IIFE
2. 识别解码器函数和嵌套包装器(多层深度)
3. **在沙箱化的 `vm` 上下文中执行原始解码器** —— 无需重新实现,无需猜测
4. 将每个解码器调用替换为恢复的字面量字符串
这就是它在其他工具失效的地方依然有效的原因:如果混淆器能解码它,Revelio 也能。
### 阶段 2 — 结构清理
移除字符串解码后残留的脚手架代码。**迭代运行直至收敛** —— 每一轮都会为下一轮暴露出新的模式。
| 阶段 | 功能 | 示例 |
|------|-------------|---------|
| 2.1 算术 | 解析常量表达式 | `-1 * 8831 + 93 * -9 + 11668` → `2000` |
| 2.2 布尔值 | 解析布尔强制转换 | `!![]` → `true`, `![]` → `false` |
| 2.3 代理对象 | 内联委托对象 | `obj.func(a, b)` → `a === b` |
| 2.4 死代码分支 | 消除总是为真/假的条件语句 | `if ('abc' !== 'abc') { dead }` → 已移除 |
| 2.4b 不可达代码 | 移除 `return`/`throw` 之后的代码 | — |
| 2.5 逗号拆分 | 将逗号表达式拆分为语句 | `a = 1, b = 2` → 两个语句 |
| 2.6 死对象 | 移除未使用的数字对象 | `const _0x = { _0xabc: 123 }` → 已移除 |
| 2.7 死代理 | 移除未使用的代理声明 | — |
### 阶段 3 — 变量重命名
将 `_0x...` 标识符重命名为根据上下文推断出的可读名称。
| 上下文 | 结果 |
|---------|--------|
| `document.getElementById('status')` | `statusEl` |
| `document.createElement('div')` | `divEl` |
| `new FileReader()` | `fileReader` |
| `new TextEncoder()` | `textEncoder` |
| `await fetch(...)` | `response` |
| `await response.json()` | `data` |
| `catch(e)` | `err` |
| `.map(x => ...)` | `item` |
| `new Promise((a, b) => ...)` | `resolve`, `reject` |
| 其他情况 | `_a`, `_b`, `_c`, … |
## 支持的模式
- ✅ 带旋转的字符串数组(包括在 SequenceExpressions 内部)
- ✅ RC4 和 base64 字符串编码
- ✅ 解码器函数和嵌套包装器(多层)
- ✅ 解码器别名(`const _h = decoder`)在所有作用域中传递解析
- ✅ 代理/委托对象(字面量和函数)
- ✅ 死代码插入(总是为真/假的条件语句)
- ✅ 逗号表达式
- ✅ 数字流控制对象
- ✅ 代理对象别名
- ✅ 布尔强制转换(`!0` → `true`, `!1` → `false`, `!![]` → `true`)
- ✅ 十六进制字面量 → 十进制(`0x1f4` → `500`)
- ✅ `void 0` → `undefined`
- ✅ 括号表示法清理(`obj["foo"]` → `obj.foo`, `["method"]()` → `method()`)
## 安装
```
git clone https://github.com/alangodoi/revelio
cd revelio
npm install
```
## 用法
```
node deobfuscate.mjs
```
清理后的文件会保存在原始文件旁边,命名为 `.deobf.js`。
### 示例
```
# 单个文件
node deobfuscate.mjs content.js
# 多个文件
for f in security.js license.js content.js; do
node deobfuscate.mjs "$f"
done
# 来自其他项目的文件
node deobfuscate.mjs /path/to/obfuscated.js
```
## 环境要求
- Node.js ≥ 18
## 依赖项
| 包 | 作用 |
|---------|------|
| [acorn](https://github.com/acornjs/acorn) | JavaScript parser → AST |
| [acorn-walk](https://github.com/acornjs/acorn/tree/master/acorn-walk) | AST traversal |
| [escodegen](https://github.com/estools/escodegen) | AST → clean JavaScript |
| [astring](https://github.com/davidbonnet/astring) | Fallback code generator for ES2022+ syntax (private fields, class properties) |
## 许可证
MIT © [Alan Godoi da Silveira](https://github.com/alangodoi)
```
MIT License
Copyright (c) 2026 Alan Godoi da Silveira
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
标签:AST 抽象语法树, Base64 解码, DNS 反向解析, GNU通用公共许可证, JavaScript 反混淆, JavaScript 混淆器, MITM代理, Node.js, RC4 解密, VM 虚拟机, Web 安全, 云安全监控, 云资产清单, 代码安全, 代码还原, 去混淆, 字符串解密, 开源安全工具, 恶意代码分析, 死代码消除, 漏洞枚举, 自定义脚本, 逆向工程, 逆向工程平台, 配置文件, 静态分析