[Hack The Box][Machine][Easy] - š§ Pandora
This is my writeup for the Pandora machine on the Hackthebox plateform.
Letās start with anĀ nmap scanĀ to enumerate the different ports that are open.
- Port 22 (SSH)
- Port 80 (HTTP)
AĀ UDPĀ port scan findsĀ port 161Ā open. This is the defaultĀ SNMP port.
SNMP
You can scan port 161 with theĀ snmpwalk toolĀ to find important information. There areĀ credentialsĀ that are used to launch a program:Ā /usr/bin/host_check.
With these credentials, we can connect in SSH. On the server is the binaryĀ host_checkĀ that we can recover on our host in order to decompile it withĀ ghidra.
GHIDRA
By decompiling the program, we learn that aĀ Pandora FMSĀ runs locally onĀ port 80. We canĀ forwardĀ it with SSH and access the web application.
PIVOT
The website is the default Pandora FMS page. To access the dashboard, you need a login and password.
After some research, this version of Pandora FMS has aĀ vulnerability. It isĀ vulnerable to SQL injectionsĀ because of theĀ chart_generator.phpĀ file. It is theĀ session_idĀ parameter that is vulnerable.
You can useĀ sqlmapĀ to dump the entire database and retrieve the information you want.
A pandora database table (tsessions_php) contains usersā PHP session cookies. Unfortunately, it does not contain that of the administrator but only those ofĀ danielĀ andĀ matt.
sqlmap --url [http://127.0.0.1/pandora_console/include/chart_generator.php?session_id=](http://127.0.0.1/pandora_console/include/chart_generator.php?session_id=) -D pandora -T tsessions_php --dump --batch
id_usuario|s:6:"daniel";
id_usuario|s:4:"matt";
EXPLOITATION
I created this script in order to retrieve theĀ administratorās cookie,Ā upload a php fileĀ where we canĀ inject commandsand thus have aĀ reverse-shell.
PRIVESC
After enumerating theĀ SUID files, we findĀ pandora_backupĀ which has these permissions. We recover it on our host toĀ decompileĀ it with theĀ ghidra tool.
This program launches theĀ tar commandĀ to create an archive of the Pandora FMS. The problem is that it uses aĀ relative pathĀ instead of anĀ absolute pathĀ (/usr/bin/tar). We can exploit this with aĀ writable path abusesĀ :Ā link
In order for it to work correctly, I added my public SSH key in the ssh folder of matt that I created. This allows me to connect in SSH instead of the reverse-shell and to have a more stable shell.