Jacquantavious/Deobfuscator-x

GitHub: Jacquantavious/Deobfuscator-x

一款基于 Babel AST 与 Web Worker 流水线的浏览器端 JavaScript 代码去混淆工具,通过多 Pass 转换将混淆代码还原为可读形式。

Stars: 0 | Forks: 0

# ⬡ Deobfuscator-X ![状态](https://img.shields.io/badge/status-Part%201%20%E2%80%94%20Foundation-00ff9d?style=flat-square) ![许可协议](https://img.shields.io/badge/license-MIT-4db8ff?style=flat-square) ![技术](https://img.shields.io/badge/stack-Vite%20%7C%20Monaco%20%7C%20Babel%20%7C%20Workers-ffe566?style=flat-square) ## 截图 ``` ┌──────────────────────────────────────────────────────────────────────┐ │ ⬡ Deobfuscator-X v1.0 0 lines · 0 B · 0 passes ◐ ⌥ │ ├─────────────────────────────────────────────────────────────────────-┤ │ ▶ Deobfuscate ✦ Beautify Only ✕ Clear ⎘ Copy ↓ Download ⚙ │ ├──────────────────────────────────────────────────────────────────────┤ │ ████████████████░░░░░░░░░░░░░░░ Running: Unicode Normalization… │ ├────────────────────────┬─────┬───────────────────────────────────────┤ │ • Input │ ║║ │ • Output │ │ obfuscated JS │ │ deobfuscated result │ │ │ │ │ │ [Monaco Editor] │ │ [Monaco Editor — readonly] │ │ │ │ │ ├────────────────────────┴─────┴───────────────────────────────────────┤ │ Log AST Info Pass Results Clear │ │ 00:00:01 INFO Deobfuscator-X ready… │ │ 00:00:02 PASS Unicode Normalization — 2.3ms │ └──────────────────────────────────────────────────────────────────────┘ ``` ## 功能特性(第 1 部分 — 基础架构) | 功能 | 状态 | |---|---| | Monaco 编辑器(输入 + 输出) | ✅ | | 磷绿色的黑客暗黑主题 | ✅ | | 浅色主题切换 | ✅ | | Web Worker pipeline(非阻塞) | ✅ | | Babel AST 解析 + 生成 | ✅ | | Prettier 代码美化 | ✅ | | Unicode `\uXXXX` 规范化 | ✅ | | 十六进制/八进制/二进制字面量规范化 | ✅ | | 数字常量折叠 | ✅ | | 死代码移除 | ✅ | | AST 简化(三元、逻辑运算) | ✅ | | 反调试器移除 | ✅ | | 带有微光效果的进度条 | ✅ | | Console 面板(Log / AST / Passes 标签页) | ✅ | | 拖拽调整编辑器面板大小 | ✅ | | 复制输出 / 下载 JS | ✅ | | 包含 11 个 pass 开关的侧边栏设置 | ✅ | | 键盘快捷键 | ✅ | | GitHub Pages 部署 | ✅ | | 大文件分块渲染(10 万+ 行) | ✅ | **第 2 部分即将推出:** `_0x` 解码器、XOR 解码、控制流重构、rotate 简化 **第 3 部分即将推出:** 运行时解包、eval hooks、高级作用域分析、标识符重命名 ## 架构 ``` deobfuscator-x/ ├── index.html # Single-page app shell ├── styles.css # Global styles (CSS custom properties) ├── vite.config.js # Vite + Monaco plugin config │ ├── src/ │ ├── main.js # App entry — bootstraps all components │ │ │ ├── core/ │ │ ├── pipeline.js # AST pipeline orchestrator │ │ ├── registry.js # Pass registration & lifecycle │ │ └── worker-bridge.js # Main-thread Worker API wrapper │ │ │ ├── passes/ │ │ ├── index.js # Central pass registry (exports all) │ │ ├── unicode-normalization.js │ │ ├── hex-deobfuscation.js │ │ ├── numeric-literal.js │ │ ├── dead-code.js │ │ ├── ast-simplification.js │ │ └── anti-debugger.js │ │ │ ├── components/ │ │ ├── editor-manager.js # Monaco init, themes, resize │ │ ├── console-logger.js # Bottom console panel │ │ └── settings-panel.js # Slide-out settings sidebar │ │ │ └── utils/ │ ├── helpers.js # Copy, download, format, debounce │ └── progress.js # Progress bar controller │ ├── workers/ │ └── deobfuscate.worker.js # Web Worker (owns the pipeline) │ └── .github/ └── workflows/ └── deploy.yml # Auto-deploy to GitHub Pages ``` ## 插件 / Pass 架构 每个去混淆 pass 都是一个实现了 `PassDefinition` 接口的普通 JavaScript 对象: ``` const myPass = { id: 'myPassId', // unique key used in toggle state name: 'My Pass', // human-readable label shown in UI description: 'What it does', // shown in settings sidebar priority: 30, // lower = runs earlier (0–99) enabled: true, // default toggle state run(ast, api) { const { traverse, types: t, log, signal } = api; traverse(ast, { StringLiteral(path) { // transform the node log('Found string literal'); }, }); }, }; ``` ### 注册 pass ``` // src/passes/index.js import { myPass } from './my-pass.js'; export function getAllPasses() { return [ // ... existing passes myPass, ]; } ``` `TransformRegistry` 负责: - 去重(重新注册时会发出警告) - 按优先级排序的执行顺序 - 与 UI 开关同步的启用/禁用状态 - 为未来 localStorage 持久化提供序列化 ### 传递 API | 属性 | 类型 | 描述 | |---|---|---| | `traverse` | `Function` | `@babel/traverse` — 遍历 AST | | `types` | `object` | `@babel/types` — 节点构建器和类型检查 | | `log` | `Function(msg)` | 将消息传送到 console 面板 | | `signal` | `AbortSignal` | 检查 `signal.aborted` 以进行取消操作 | ## Worker 通信协议 ``` Main Thread Worker │ │ │── { type: 'RUN', payload } ──▶│ │ │── parse AST │◀── { type: 'PROGRESS' } ──────│── run pass 1 │◀── { type: 'PROGRESS' } ──────│── run pass 2 │◀── { type: 'PROGRESS' } ──────│── generate │◀── { type: 'RESULT' } ────────│── done │ │ │── { type: 'ABORT' } ─────────▶│ │◀── { type: 'ABORTED' } ───────│ ``` `WorkerBridge` 将其封装为一个干净的 Promise API: ``` const result = await bridge.run({ code, options: { beautifyOnly: false }, passes: { unicodeNormalization: true, deadCode: true }, onProgress: ({ progress, label }) => console.log(progress, label), }); ``` ## 键盘快捷键 | 快捷键 | 操作 | |---|---| | `Ctrl/Cmd + Enter` | 执行完整去混淆 | | `Ctrl/Cmd + Shift + B` | 仅美化代码 | | `Ctrl/Cmd + ,` | 切换设置面板 | | `Escape` | 关闭设置面板 | ## 设置与开发 ### 前置条件 - Node.js 18+ - npm 9+ ### 安装 ``` git clone https://github.com/YOUR_USERNAME/deobfuscator-x.git cd deobfuscator-x npm install ``` ### 开发服务器 ``` npm run dev # → http://localhost:3000 ``` ### 生产环境构建 ``` npm run build # → dist/ ``` ### 预览生产环境构建 ``` npm run preview ``` ## GitHub Pages 部署 ### 一次性设置 1. 在 GitHub 上 **Fork / 创建仓库** 2. **更新 `vite.config.js`** — 修改 `base` 以匹配你的仓库名称: base: '/your-repo-name/', 3. 在你的仓库设置中 **启用 GitHub Pages**: - 进入 **Settings → Pages** - Source: **GitHub Actions** 4. **推送到 `main`** — workflow 将自动运行: git add . git commit -m "initial deploy" git push origin main 5. 你的应用已上线,访问地址: https://YOUR_USERNAME.github.io/deobfuscator-x/ ### Workflow 概览 `.github/workflows/deploy.yml` 文件将执行以下操作: 1. 每次推送到 `main` 时触发 2. 使用 `npm ci` 安装依赖 3. 使用 `vite build` 进行构建 4. 将 `dist/` 作为 Pages artifact 上传 5. 部署到 GitHub Pages ## 技术栈 | 包名 | 用途 | |---|---| | [Vite](https://vitejs.dev) | 构建工具与开发服务器 | | [Monaco Editor](https://microsoft.github.io/monaco-editor/) | 代码编辑器 | | [@babel/parser](https://babeljs.io/docs/babel-parser) | JavaScript AST 解析 | | [@babel/traverse](https://babeljs.io/docs/babel-traverse) | AST 遍历 | | [@babel/generator](https://babeljs.io/docs/babel-generator) | AST → 代码生成 | | [@babel/types](https://babeljs.io/docs/babel-types) | AST 节点构建器 | | [Prettier](https://prettier.io) | 代码格式化 | | [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) | 非阻塞处理 | ## 路线图 ### 第 1 部分(当前构建)— 基础架构 ✅ 基础架构、编辑器 UI、Babel pipeline、安全的代码转换 ### 第 2 部分 — 高级字符串解码 🔜 - `_0x` 数组解码器恢复与内联 - XOR / 轮换密码解码 - 控制流平坦化还原 - 数组轮换简化 ### 第 3 部分 — 深度分析 🔜 - 通过沙箱化 eval 进行运行时解包 - eval hook 拦截 - 感知作用域的标识符重命名 - 原型链分析 - 基于引用计数的死代码移除 ## 许可协议 MIT © 2024 — 用 ⬡ 和 00ff9d 构建
标签:Babel, Monaco Editor, Vite, 代码反混淆, 代码美化, 数据可视化