这是我第一次将恶意漏洞利用移植到 Nuclei 模板中,用于非侵入式漏洞扫描,同时仍能演示底层问题。
我特意将这一过程记录得更加详细,作为一次学习练习。
我遇到的主要挑战是:
-itags local 参数而受阻,因为本地标签在 .nuclei-ignore 设置中默认被忽略。我选择在 Windows 环境中进行此活动可能看起来有些奇怪。事实上,Windows 是我的默认操作系统,原因这里就不赘述了。
docker-compose up --build -d
此模板使用 code 引擎,出于安全原因需要签署。本仓库中的模板已签署。
docker-compose.yaml 已配置为将您的 Windows Nuclei 签署密钥从 %APPDATA%\nuclei\keys 挂载到容器中。这样可以验证已签署的模板。
在 Windows 主机上(需要安装 Nuclei)。
nuclei -t cve-2025-32463.yaml -sign
这将签署模板并添加摘要字段。
注意: 首次运行此命令时,Nuclei 将在 %APPDATA%\nuclei\keys 中创建签署密钥,并提示输入:
Linux/macOS/Git Bash:
docker exec -u testuser vulnerable-sudo-target sh -c 'nuclei -itags local -t /tmp/template.yaml -target localhost -code'
Windows PowerShell/CMD:
docker exec -u testuser vulnerable-sudo-target sh -c "nuclei -itags local -t /tmp/template.yaml -target localhost -code"
替代方案(适用于所有平台):
docker exec -u testuser vulnerable-sudo-target nuclei -itags local -t /tmp/template.yaml -target localhost -code
注意:
-code 标志才能启用基于代码协议的模板sh -c '...' 以避免 MSYS2/Git Bash 的 Windows 路径转换问题[INF] Executing 1 signed templates from <your-username>Windows PowerShell/CMD:
docker exec -u testuser patched-sudo-target sh -c "nuclei -itags local -t /tmp/template.yaml -target localhost -code"
替代方案(适用于所有平台):
docker exec -u testuser patched-sudo-target nuclei -itags local -t /tmp/template.yaml -target localhost -code
注意:
-code 标志才能启用基于代码协议的模板"..." 或不带 sh -c 的替代命令[INF] Executing 1 signed templates from <your-username>如果您想在不签署 Nuclei 模板的情况下验证漏洞,可以直接运行漏洞利用脚本:
复制并运行漏洞利用脚本。
docker cp exploit.sh vulnerable-sudo-target:/tmp/exploit.sh
docker exec -u testuser vulnerable-sudo-target bash /tmp/exploit.sh
预期输出:woot! 后跟一个 root shell(在交互模式下)。
[CVE-2025-32463] [code] [critical] localhost ["VULNERABLE UID=1000 EUID=0"]
[INF] Executing 1 signed templates from <your-username>
[INF] Scan completed in 140.454595ms. 1 matches found.
检测确认: UID=1000 EUID=0 证明来自 testuser(1000)的代码以 root 权限(0)执行。
[INF] Executing 1 signed templates from <your-username>
[INF] Scan completed in 143.319373ms. No results found.
未检测到漏洞 - 已修补的 sudo 版本阻止了库加载。
有关漏洞的详细技术说明、攻击向量和检测方法,请参阅 技术说明 文档。