~/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

target:: Notion MEDIUM date:: 2026.07.26 notion

Pistas

  1. Check the root (’/’) directory for a file that might hold the key to the first flag on target1.ine.local.

  2. 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.

  3. Investigate the user’s home directory and consider using ‘libssh_auth_bypass’ to uncover the flag on target2.ine.local.

  4. 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- target​1.ine.​local
Notion image
Notion image

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

Notion image
Notion image

La web principal nos redirige a un .cgi vamos a comprobar si es vulnerable con nmap

nmap --script http-s​hellsh​ock --scri​pt-arg​s "http-s​hellsh​ock.ur​i=/bro​wser.c​gi" target​1.ine.​local
Notion image
Notion image

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

Notion image
Notion image

Ahora abrimos una shell con shell y /bin​/bas​h -i para hacerla interactiva, para buscar todas las flag, usamos este comando find

find / -iname *flag*.txt 2>/dev/null
Notion image
Notion image

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- target​2.ine.​local
Notion image
Notion image

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

libssh 0.8
Notion image
Notion image

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

Notion image
Notion image

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
Notion image
Notion image

Lo ejecutamos para ver su comportamiento:

./welcome
Notion image
Notion image

Vamos a ver que cadenas hay dentro del binario:

strings welcome
Notion image
Notion image

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
Notion image
Notion image

Ejecutamos para escalar privilegios

./welcome
Notion image
Notion image

Y en /root encontramos la última flag: FLAG4_935f044eed8b4d75be77f565ee7cad6b


- EOF -

<< back_to_index