Tenet
Gaining Access
Nmap scan:
$ nmap -p- --min-rate 5000 10.129.85.1
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-30 08:28 EDT
Nmap scan report for 10.129.85.1
Host is up (0.0071s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open httpAnother web-based exploit. We have to add tenet.htb to our /etc/hosts file to view the website.
Tenet PHP Deserialisation
The machine has a blog-like website:

This is a Wordpress based site if we view the page source. If we view some of the comments within the pages, we can see this comment that points us towards another file:

Visiting sator.php won't do anything. Instead, visithttp://<IP>/sator.php.bak, and it would download file to our machine. Then, we can view the file contents:
This was an obvious deserialisation exploit at the sator.php file hosted on the IP address. As such, we can create this small bit of code that would write a new file to the machine.
When run in PHP, it wouuld create a PHP Serialised object. Then, we just need to send that within the arepo parameter in a GET request to sator.php:
Afterwards, we can confirm we have RCE on the machine:
Just spawn a reverse shell using a basic bash shell next.

Privilege Escalation
Wordpress Credentials
Now that we are in, we can read the wp-config.php file. We would find some credentials in it:
We can then just su to neil and grab the user flag.
Sudo Race Condition
When we check sudo privileges, we see this:
Here's the script:
This script is a classic example of a race condition attack. Since the key is temporarily created within the /tmp directory before being added to the authorized_keys folder of root, we can intercept the response by having a loop running within the /tmp directory that checks for the key's creation, then overwrite the file with my own key.
After a while, we should get an error like this:

Then we can just SSH to root.

Rooted!