datnt1-tech/r2web

GitHub: datnt1-tech/r2web

一个基于 Ghidra + radare2 的拖放式 Web UI 工具,利用多核并行将原生二进制反编译为单个可读的 C 源码文件。

Stars: 1 | Forks: 0

# r2web 一个用于通过 **Ghidra + radare2** 反编译原生二进制文件的拖放式 Web UI, 可在**每个 CPU 核心上并行**运行反编译器。将 `.so` / ELF / `.o` / `.a` / `.bin` 拖放到页面上,即可获得一个可直接阅读的 `.c` 文件。 - **零 pip 依赖** — 纯 Python 标准库 (`http.server`)。 - **并行反编译** — 仅分析一次,然后将函数分配给 N 个 radare2 worker 进程(N = 你的 CPU 核心数)并行处理,并实时流式传输进度。 - **项目 = 文件夹** — 每个项目都是 `~/r2web/` 下的一个普通目录。 创建项目并在它们之间切换,输出的 `.c` 文件将存放在你选定的项目目录中。 - **在你的文件管理器中打开** — 点击结果即可在 Dolphin (或你的操作系统默认文件管理器)中显示其所在文件夹,然后在你喜欢的任何 IDE 中打开它。 - 采用深绿色终端风格的 UI,工作区居中。 📐 **完整的架构说明 + 图表:** [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) ## 工作原理 ``` drop file ──HTTP POST /api/decompile──▶ radare2 analysis (aaa) │ discover functions (aflj) ▼ split functions ──▶ N × [ r2 -i script (af; pdg @addr) ] │ each worker streams markers ▼ concatenate ──▶ one .c in ~/r2web// ``` `pdg` 是通过 **r2ghidra** 插件在 radare2 中暴露出来的 Ghidra 反编译器。 可在 **Linux** 和 **macOS** 上运行。 ## 环境要求 | 工具 | 用途 | Arch / CachyOS | macOS | |------|---------|----------------|-------| | `python3` | 后端(仅标准库) | `sudo pacman -S python` | 已预装 / `brew install python` | | `radare2` | 分析与调度 | `sudo pacman -S radare2` | `brew install radare2` | | `r2ghidra` | `pdg` Ghidra 反编译器 | `r2pm -Uci r2ghidra` | `r2pm -Uci r2ghidra` | 可选:用于“打开文件夹”按钮的文件管理器 — Linux 上的 Dolphin/Nautilus/…, macOS 上的 **Finder**(通过 `open -R` 自动调用)。 还没有安装 radare2/r2ghidra?运行自带的安装程序(自动检测 Arch/Debian/Fedora/…;通过系统包管理器安装 radare2,通过 `r2pm` 安装 r2ghidra): ``` ./install-deps.sh ``` ## 安装 ``` git clone https://github.com/datnt1-tech/r2web.git cd r2web ./install-deps.sh # (optional) install radare2 + r2ghidra ./install.sh # symlinks `r2web`, installs the icon + .desktop entry (no root) ``` 然后在终端中运行: ``` r2web # starts the server and opens the browser at http://127.0.0.1:8765 ``` …或者从你的应用程序菜单中启动 **“r2web decompiler”**。在 **Linux** 上,`install.sh` 会添加一个 `.desktop` 条目和图标;在 **macOS** 上,它会构建 `~/Applications/r2web.app` (包含 `.icns` 图标),并在 Terminal 窗口中打开服务器。无论哪种方式, 启动器都会在其 Terminal 窗口的前台运行服务器 — **按下 Ctrl+C 或 关闭窗口即可停止它**(它不是后台 daemon)。 你也可以在不安装的情况下直接运行它: ``` ./run.sh ``` ## 用法 1. 选择或创建一个 **项目**(位于顶部标题栏的下拉菜单中 — 项目是 `~/r2web/` 下的文件夹,与默认的 `tmp` 同级)。 2. **将二进制文件拖放**到页面的任何位置(或点击 **⬆ Decompile file**)。 3. 查看实时进度(函数数/秒、线程数、已用时间)。 4. 完成后,新的 `.c` 会出现在文件列表中。重名文件会添加 `(1)`, `(2)`, … 后缀。点击它即可在你的文件管理器中打开其所在文件夹。 ## 配置 环境变量(由 `run.sh` / `server.py` 读取): | 变量 | 默认值 | 含义 | |-----|---------|---------| | `R2WEB_HOST` | `127.0.0.1` | 绑定地址 | | `R2WEB_PORT` | `8765` | 端口 | 项目根目录为 `~/r2web/`;默认项目 `tmp` 会在首次启动时创建。 ## 目录结构 ``` server.py # backend: HTTP API + parallel decompile orchestration run.sh # foreground launcher (kills any stale server, opens browser) static/index.html # single-file frontend (UI + JS) install.sh # installs launcher, icon, desktop entry under ~/.local assets/ # icon (svg + png) and .desktop template ``` ## License MIT — 详见 [LICENSE](LICENSE)。
标签:Ghidra, Python, radare2, TCP SYN 扫描, Web UI, 二进制分析, 云安全运维, 云资产清单, 反编译器, 应用安全, 无后门, 逆向工具, 逆向工程