HackTheBox "Precious"
April 16th, 2023

Introduction
Precious is an easy box released on November 26th, 2022 by Nauten.
User Own
Nmap:
There's a website being hosted at http://precious.htb.

Messing around with the website in Burp Suite reveals the PDFs are being generated with pdfkit 0.8.6, which is vulnerable. Using this script from Exploit-DB lets us inject commands into the website, giving us a reverse shell in Ruby.
After gaining a reverse shell, we are logged in as ruby in the directory /var/www/pdfapp. Checking /home reveals that ruby has a home directory.
Checking /home/ruby/.bundle/config reveals henry's credentials.
These credentials can be used to login to SSH as henry and get the user.txt flag.

System Own
henry has a file called dependencies.yml.
It seems this file will cat /root/root.txt when read, which is what we want.
sudo -l reveals:
/opt contains:
update_dependencies.rb does:
update_dependencies.rb grabs dependencies.yml, but does so relatively. We can run this script as root and use the dependencies.yml in henry's home directory instead of the one in /opt/sample. This will print out the root.txt flag.

That's the box completed!

Last updated