Sau Writeup

Enumeration

As with every machine, I like to start off with an nmap scan of all TCP ports using the standard NSE scripts and gather version information. Additionally, I did a scan of the top UDP ports. The results of the scans show TCP ports 22, 80, 8338, and 55555 as open as well as UDP port 68 being open. Looking closer at the results, TCP ports 80 and 8338 are showing as filtered. This means there is a firewall or filter in place that is preventing a successful connection from the attack box to the target box.

Initial Access

When TCP port 22 is open I like to check if there is low hanging fruit by doing a brute force attack with common usernames and passwords. In this case no valid credentials were found.

As stated previously, TCP ports 80 and 8338 are showing as filtered. This was confirmed by connecting to the target machine’s IP in a browser and specifying the two ports. Each request eventually timed out. The only port left to check is TCP port 55555. After starting Burpsuite and opening its browser I navigate to the target machine’s IP and specified TCP port 55555. The purpose of using Burpsuite is to proxy the web traffic for analysis. The web requests can be viewed for any sort of information leakage in the headers such as software or version information. It also allows for the modification of web requests but at this point there is no need for that. The functionality of the web page seems fairly basic at first glance. Looking towards the bottom of the page is software and version information. Doing a Google search for “request baskets 1.2.1” reveals CVE-2023-27163.

I like to have some sort of enumeration going on in the background so before I dive too deep into researching the CVE I started a directory and file brute force against the web application.

CVE-2023-27163 is a Server-Side Request Forgery (SSRF) vulnerability that can be exploited and can allow an attacker access to internal network resources or other sensitive information via a specially crafted API request. Additional information about the CVE can be found here – https://nvd.nist.gov/vuln/detail/CVE-2023-27163. Exploiting this vulnerability could bypass the filter in place that is preventing me from accessing TCP ports 80 and 8338.

The NIST website had the following Github page listed in the resource section – https://gist.github.com/b33t1e/3079c10c88cad379fb166c389ce3b7b3. It lays out exactly how to take advantage of the SSRF vulnerability. First thing that that needs to be done is create a basket.

After opening the basket, some changes to the configurations need to be made.

Clicking on the Settings button opens up the following menu. On the left is the basket settings and on the right is the Github page explaining how the vulnerability can be exploited. The exploit works by using the target system running request-baskets as a proxy to access internal resources that are not publicly available. Say, for example, the target system running request-baskets is also hosting a web server on TCP port 80. The target system has an iptables rule in place that only allows access to it via 127.0.0.1 , all other requests are dropped. Now if a request is made from the attack box to the target box in an attempt to access TCP port 80, it will be blocked based off that rule. By taking advantage of the SSRF however, the same request from the attack box will be proxied by the target system and will be allowed because the server is “tricked” into making the request itself. A more detailed explanation of SSRF can be found here – https://portswigger.net/web-security/ssrf.

Back to exploiting CVE-2023-27163. The forward_url parameter identifies where the request will be sent to. In this case I want to access TCP port 80. After a bit of trial and error I figured out that the Proxy Response setting needs to be enabled to interact with the internal web server.

With everything configured properly I hit Apply. After hitting OK I copy the URL for the basket that was just created and had its settings modified.

Success! Navigating to the basket’s URL triggers the vulnerability and I am able to access the internal web server on TCP port 80. Turns out TCP port 80 is running Maltrail v0.53 and it has a remote code execution (RCE) vulnerability. Going back to the NIST page above, there is a link in the resource section that contains a script for RCE – https://packetstormsecurity.com/files/174129/Maltrail-0.53-Remote-Code-Execution.html.

After reviewing the script it was discovered that an adjustment to the bucket settings needed to be made. Let me explain. Currently, traffic sent to http://{$TGT}/{bucket} is being forwarded to http://127.0.0.1:80/. However, the exploit takes advantage of a vulnerability in the Maltrail /login page. If the script is ran in the bucket’s current configuration the payload would be sent to http://{$TGT}/{bucket}/login which would obviously fail.

To fix that I need to go back and adjust the forward_url parameter so that it points to the Maltrail login page.

After making that change I was able to successfully run the script and get a callback!

Privilege Escalation

The first thing that I like to do after gaining initial access to a system is manual enumeration. My go to commands are as follows:
ip a
id
sudo -l
env
cat /etc/*release
uname -a
netstat -natplu

These commands provide situational awareness and help guide what the next steps should be. After doing my initial check I can see the user puma can run systemctl with sudo and no password is needed. Which is perfect because I do not have the user’s credentials. A quick search on GTFOBins shows that if a user can run systemctl with sudo, it is possible to get a root shell – https://gtfobins.github.io/gtfobins/systemctl/.