Cache
Gaining Access
Nmap scan:
$ nmap -p- --min-rate 5000 10.129.211.212
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-10 10:30 EDT
Nmap scan report for 10.129.211.212
Host is up (0.0089s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open httpAccidental Subdomain Enum
Port 80 reveals a blog like website:

There's not much here, but we can add cache.htb to our /etc/hosts file since there's a banner for it on screen. I ran a gobuster and wfuzz scan on the machine. Funnily, I accidentally had a typo in my wfuzz command, and found a completely new domain present:
hms.htb is active on this machine. We can visit that.
OpenEMR
The page shows us a login for OpenEMR, which is known to have a ton of vulnerabilities:

We can head to the Github Repo for this software and attempt to find its version using the default files present:
Visiting sql_patch.php reveals that this is OpenEMR 5.0.1:

This version has quite a few RCE exploits for it:
There's also an authentication bypass exploit here:
To bypass it, all we have to do is simply visit /portal/account/register.php, and it would treat us as logged in with a valid token. Searching for exploits led me to a PDF that had the vulnerability report for v5.0.1.3, and there are lot including a lot of SQL Injections.
Firstly, visiting /portal/find_appt_popup_user.php just works as we have 'bypassed' the login.

For this case, the second PoC listed works best.

Using sqlmap, we can enumerate and view the stuff in the database. (skipped the enumeration)
We can crack this hash in john.
Now that we have the admin password, we can do RCE.
Remember to use python2.

Privilege Escalation
Ash Creds
I searched all the files within /var/www except for OpenEMR for credentials:
So here's the stuff within that file:
Using that password, we can su to ash.

Memcache
When we enumerate the ports that are open, we can see that port 11211 is listening:
This is the memcache service.
We can enumerate the items within it:
We can grab the password and su to luffy.
Docker Group
luffy is part of the docker group.
We can just run this command to create an Ubuntu container that is mounted on the main file system, where we have access to the container as root. This effectively gives us root access to the main file system to make /bin/bash an SUID binary.
Then we can exit this and get a shell with EUID of root.
