Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
cve-2026-42945-scan — 扫描您的 NGINX 配置以确定是否受到 CVE-2026-42945 的影响。 | Kitploit
工具/GitHubGitHub/realityone/cve-2026-42945-scan
静态分析漏洞扫描器配置审计Web安全错误配置
GitHubrealityone/cve-2026-42945-scan

cve-2026-42945-scan

扫描您的 NGINX 配置以确定是否受到 CVE-2026-42945 的影响。

查看仓库
13个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

cve-2026-42945-scan

针对 NGINX 配置文件的静态扫描器,用于检测与 CVE-2026-42945 相关的 rewrite/set 模式。

该扫描器使用 crossplane 解析 NGINX 配置,遍历 location 块,并打印每个疑似受影响的 location,格式如下:

root@kitploit:~
/<path-to>/xxx.conf:<line-number> -> location XXXXX

示例:

root@kitploit:~
/path/to/nginx.conf:39 -> location ~ ^/api/(.*)$

参考:CVE-2026-42945-POC。

要求

  • Python 3.10 或更高版本
  • uv

依赖项通过 uv 在 pyproject.toml 中管理,并在 uv.lock 中锁定。唯一的运行时依赖是 crossplane。

设置

在仓库根目录下执行:

root@kitploit:~
uv sync

你也可以跳过单独的设置步骤,让 uv run 在首次使用时自动创建环境。

用法

扫描单个配置文件:

root@kitploit:~
uv run ./scan.py /etc/nginx/nginx.conf

递归扫描目录:

root@kitploit:~
uv run ./scan.py -r /etc/nginx

从当前目录递归扫描所有 *.conf 文件:

root@kitploit:~
uv run ./scan.py -r './*.conf'

如果你希望扫描器递归展开 glob 模式,请用引号引用。如果你的 shell 先展开了 ./*.conf,则扫描器只能接收 shell 匹配到的文件。

仅扫描提供的文件,不跟随 include 指令:

root@kitploit:~
uv run ./scan.py --single ./site.conf

显示解析器警告,包括缺失的 include 文件:

root@kitploit:~
uv run ./scan.py -v -r /etc/nginx

Go 版本

go/ 目录下提供了一个 Go 实现,输出格式和退出码与 Python 版本相同。它使用 nginx-go-crossplane 解析 NGINX 配置,使用 pflag 处理 CLI 参数。需要 Go 1.23 或更高版本。

使用 go run 运行:

root@kitploit:~
cd go
go run . -r ../tests/fixtures

当发现结果时,扫描器退出码为 1。在这种情况下,go run 会额外输出一行 exit status 1;如果只想看到扫描器输出,请编译为二进制文件。

编译独立的二进制文件:

root@kitploit:~
cd go
go build -o cve-2026-42945-scan-go .
./cve-2026-42945-scan-go -r ../tests/fixtures

检测内容

有风险的配置模式是 location 中包含:

  • 一条 rewrite 指令,其替换内容中包含未转义的 ?
  • 没有 terminal rewrite 标志(如 last、break、redirect 或 permanent)
  • 其后的一条 set 指令复制了正则捕获,例如 $1、${1}、$name 或 ${name}

示例漏洞模式:

root@kitploit:~
location ~ ^/api/(.*)$ {
    rewrite ^/api/(.*)$ /internal?migrated=true;
    set $original_endpoint $1;
}

扫描器报告的是 location 行,而不是 rewrite 或 set 行,因为 location 是可操作、需要检查和修复的块。

测试夹具

tests/fixtures/ 目录包含一些小的 NGINX 配置文件,可用作示例:

对所有示例夹具运行扫描器:

root@kitploit:~
uv run ./scan.py -r tests/fixtures

预期输出:

root@kitploit:~
/absolute/path/to/tests/fixtures/missing_include_still_scans.conf:6 -> location ~ ^/partial/(.*)$
/absolute/path/to/tests/fixtures/named_capture.conf:2 -> location /users
/absolute/path/to/tests/fixtures/vulnerable.conf:2 -> location ~ ^/api/(.*)$

输出

如果发现受影响的 location,每项发现会单独打印在一行:

root@kitploit:~
/absolute/path/to/file.conf:30 -> location ~ ^/aaaa/dddd/(.*)$
/absolute/path/to/nginx.conf:39 -> location ~ ^/api/(.*)$

无输出表示在已解析的配置中未发现受影响的 location。

局限性

这是一个静态配置扫描器。它不会:

  • 验证运行中的 NGINX 版本
  • 证明漏洞的可利用性
  • 执行或测试对服务器的请求
  • 完全评估动态变量或生成的配置
  • 检测隐藏在缺失 include 文件中的漏洞代码片段

请将发现视为需要审查和修复的位置。只有当存在有漏洞的 NGINX 版本范围和有风险的配置模式时,主机才真正受影响。

开发

运行测试套件:

root@kitploit:~
uv run python -m unittest discover -s tests -v

运行 Go 测试套件:

root@kitploit:~
cd go
go test ./...

运行语法检查:

root@kitploit:~
uv run python -m py_compile scan.py

针对附带的 POC 配置运行:

root@kitploit:~
uv run ./scan.py CVE-2026-42945-POC/env/nginx.conf

预期输出:

root@kitploit:~
/absolute/path/to/CVE-2026-42945-POC/env/nginx.conf:39 -> location ~ ^/api/(.*)$
下载工具
夹具预期结果
tests/fixtures/vulnerable.conf报告位置捕获发现
tests/fixtures/named_capture.conf报告命名捕获发现
tests/fixtures/missing_include_still_scans.conf即使 include 缺失,仍报告发现
tests/fixtures/safe_break_flag.conf无发现,因为 rewrite 使用了 break
tests/fixtures/safe_no_capture.conf无发现,因为没有可用捕获