πŸ“Include

License

The following post by anthonyjsaab is licensed under CC BY 4.0arrow-up-right

0 - Introduction

Machine version: includev1.33

Use your server exploitation skills to take control of a web app.

Created by tryhackmearrow-up-right, 1337rcearrow-up-right, and l000g1carrow-up-right

1 - Port Scans

1a - Discovery

1b - Versioning and OS fingerprinting

1z - What we know so far

  • No easy wins (critical CVE exploits or other)

  • We have 2 HTTP servers, SSH enabled and multiple ports for email

2 - Review App

2a - Exploring

Landing page. We do as it is written and login using guest guest
Dashboard after login
View Profile

2b - Mass assignment

Submitting test1 and test2 adds it directly to our profile properties
Overwrote isAdmin property with something different than false.By doing so, we exploited a mass assignment vulnerability. We now have access to new admin-only sections of the website
API documentation shows a server is bound to 127.0.0.1:5000. It means the server is not publicly exposed. We need a way to do an SSRF and get the results

2c - SSRF

Settings page. It seems we can let the server make requests on our behalf.
After submitting http://127.0.0.1:5000/getAllAdmins101099991arrow-up-right as Banner Image URL, we get this output in base64

2z - What we know so far

We now have credentials to the ReviewApp (port 4000) and the SysMonApp (port 50000. We know that by simply visiting port 50000).

3 - SysMonApp

3a - Exploring and first flag

Landing page of port 50000
Using the credentials retrieved from the private server on port 5000
First flag!

3b - LFI

Looking at the source code of the dashboard, the only interesting component is the profile picture's URL: http://include.thm:50000/profile.php?img=profile.pngarrow-up-right

It seems PHP is including the PNG file (aka rendering it). That is why the rendering is terrible

It looks like the web app is using the parameter img to access a specified file on the filesystem. Maybe it is vulnerable to a directory traversal.

To test this potential attack vector, we intercept a normal request to the profile picture using Burp:

Make sure you are logged in to port 50000 before intercepting the request. Trying to send requests without proper cookies will always redirect you to the login page

For the payload, we will use the one built into Burp:

Voila! Sorting by length, we notice that one of the attempts successfully returned the /etc/hosts file. This is amazing!

Now that we uncovered the proper way to exploit the directory traversal vulnerability, we need to find a way to access the mysterious flag file located in /var/www/html (as specified in the room on TryHackMe). If we knew the filename, it was probably game over. But we don't. We need to find a way to ls into /var/www/html.

3c - Looking for a log file to poison

This is the request that successfully returned the contents of /etc/hosts.
We will send requests to retrieve well-known files on Debian.
Suprisingly, there was no log file for Apache. Luckily, there is one for SSH! (shown above)

3d - Log Poisoning

3di - Testing that it works

3dii - Sending the payload

The below payload was retrieved from https://revshells.com/arrow-up-right

Executing ls in /var/www/html. We found the filename!
Final Flag πŸŽ‰

Last updated