HTB - Time

Overview

Short description to include any strange things to be dealt with...This machine was dissapointingly easy for a medium box. It definitely should have been classified 'Easy'. A simple test at the beginning revealed a verbose error message. Some quick googling leads to an easy to use exploit. After that simple enumeration leads to a weakly protected script that gets executed as root, and leaves the player a million routes to root through arbitrary code execution.

Useful Skills and Tools

Useful thing 1

  • description with generic example

Useful thing 2

  • description with generic example

Enumeration

Nmap scan

I started my enumeration with an nmap scan of 10.10.10.214. The options I regularly use are: -p-, which is a shortcut which tells nmap to scan all ports, -sC is the equivalent to --script=default and runs a collection of nmap enumeration scripts against the target, -sV does a service scan, and -oA <name> saves all types of output (.nmap,.gnmap, and .xml) with filenames of <name>.

ony two ports open, 22- SSH, and 80 - HTTP

port 80 HTTP

Did a test for XSS, got an unhandled Java exception

Checked the source code for the page, noticed a file main.js

^--nothing?

Searched for exploits related to com.fasterxml.jackson.core

https://blog.doyensec.com/2019/07/22/jackson-gadgets.html

https://www.sourceclear.com/vulnerability-database/security/remote-code-execution-rce-through/java/sid-3929

test.sql

AFter some testing, I discovered that the POC code had some \ that they were using to excape the quotes. These were causing the validator in this case to throw an error.

After I removed them from my code I got a connection back, downloading my test.sql.

I got a connection back on my machine, proving the remote code execution worked. Next I replaced the id command with a reverse shell.

Initial Foothold

After changing the code in my test.sql file and sending it again, I recieved a reverse shell from the machine. I quickly upgraded to a full TTY and began enumeration.

index.php for the json validator site had some interesting code in it

Road to User

Further enumeration

Finding user creds

User.txt

After checking pericles' home directory I found the user.txt proof!

Path to Power (Gaining Administrator Access)

Enumeration as pericles

in lxd directory

I did a search for files that the group pericles had access to.

The exploit code that I had used to access the machine was saved as a file in /dev/shm apparently.

I also found the file /usr/bin/timer_backup.sh. It looked like it was probably a cron script that made backups of the website data. I decided it would be a good place to check to see if there was anything interesting in old backups

I searched through all of the crons and didn't find the script.

Next, I used grep to search for the name of the script in all of the files in /etc and got a hit in the systemd/system/web_backup.service file.

This service was running as root.

I double checked the permissions on the script, and saw that it was fully owned by pericles, and I could both read and write it. I decided to change the script to do a backup of root's Private key.

Getting a shell

Unfortunately it appeared as if there was no id_rsa file, or the script was not running as root.

Next I changed the script so it would send me the user ID information of the context the script was being run under

It was definitely running as root.

Next I tried sending my SSH public key to root's authorized_keys file. Each time I modified the script it only took a few seconds until it connected back, but just in case I added a message to let me know when it was done.

Root.txt

And that was it!

note: If you ran script earlier to log your console, make sure to type exit until you get the "Script done." message, back on your box.

Thanks to egotisticalSW & felamos for something interesting or useful about this machine.

If you like this content and would like to see more, please consider buying me a coffee!

Last updated

Was this helpful?