Post

HTB Windows Medium: Hospital

Hospital is a Medium rated Windows machine on HTB.

HTB Windows Medium: Hospital

Nmap

Pasted image 20240714194100.png Pasted image 20240714194053.png

Initial Foothold

Reveals domain (DC.hospital.htb & hospital.htb), add the domains to hosts file. Pasted image 20240714194048.png

Enumerating HTTP (Port 8080)

Visiting the webpage redirects us to a login page. Pasted image 20240714194042.png

Default credentials don’t seem to work (admin:admin), make an account instead. Pasted image 20240714194037.png

After logging in we get redirected to the index.php page where we can upload files (we are only allowed to upload image files). Pasted image 20240714194030.png

We can successfully upload .phar files, uploading our p0wnyshell script results in the following: Pasted image 20240714194024.png

We can now get a reverse shell. Pasted image 20240714194020.png

In the config.php file we find some database credentials root:my$qls3rv1c3!. Pasted image 20240714194014.png

After upgrading our shell we can enumerate further, since the box is running ubuntu with kernel version 5.19 we can use the gameoverlay exploit to become root. Pasted image 20240714194010.png

In the shadow file we find the password hash for drwilliams. Pasted image 20240714194005.png

Cracking the password reveals the following qwe123!@#. Pasted image 20240714193958.png

These credentials can be used to log into the web interface that is running on port 443 drwilliams:qwe123!@#. Pasted image 20240714193954.png

On the website we find an email revealing the usage of .eps files and ghostscript. Pasted image 20240714193949.png

Since we know that the web application is running ghostcript we can look for ghostcript vulnerabillities, use the following commands to create a payload (upload nc.exe). Pasted image 20240714193943.png

Next up we can upload our payload and send an email to drbrown with our payload attached. Pasted image 20240714193938.png

Now we can do the same thing for our reverse shell. Pasted image 20240714193934.png

Priv Esc

Once we are in the system we can find chris browns credentials in the ghostscript.bat file drbrown:chr!$br0wn. Pasted image 20240714193927.png

The xampp stack appears to be running as the nt authority/system user. Since we have write permissions over the htdocs directory, we can upload a web shell and get a privileged shell. Pasted image 20240714193910.png

Looks like we can simply retrieve the root flag. Pasted image 20240714193904.png

We now have a shell as the NT authority/SYSTEM user. Pasted image 20240714193837.png

User.txt

Pasted image 20240714193831.png

Root.txt

Pasted image 20240714193824.png

You have PWNED!!!

Pasted image 20240714193817.png

Sources

This post is licensed under CC BY 4.0 by the author.