
Week 8. Trickster
TL;DR
This is an Ubuntu 22.04 machine hosting an online shop made with vulnerable PrestaShop CMS (CVE-2024-34716). We exploit this to get an initial shell, then move laterally to a low-priv user after finding credentials in PHP configuration files. Regarding escalation, first we pivot to an internal host that runs a version of changedetection.io vulnerable to SSTI (CVE-2024-34716). Once we gain access to this host, we find credentials to move laterally to another user who has permissions to run as root a vulnerable PrusaSlicer 2.6.1 binary.
KEYWORDS
PrestaShop 8.1.5, CVE-2024-34716, pivoting, changedetection.io 0.45.20, CVE-2024-32651, SSTI, nuclei, brotli, PrusaSlicer 2.6.1.
REFERENCES
https://github.com/lijiejie/GitHack
https://www.cvedetails.com/cve/CVE-2024-34716/
https://github.com/aelmokhtar/CVE-2024-34716
https://www.cvedetails.com/cve/CVE-2024-32651/
https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2024/CVE-2024-32651.yaml
https://fileinfo.com/extension/br
https://www.exploit-db.com/exploits/51983
ENUMERATION
Port scan.
Enumerate the open ports.
Update hosts file and enumerate the site with Firefox.

If we navigate thought the web site, we find another subdomain shop.trickster.htb, that seems to have been built with PrestaShop CMS.

If we fuzz for hidden contents we find the .git folder.
This can be downloaded with GitHack tool (https://github.com/lijiejie/GitHack) so we have a look at the structure of the .git directory.
Navigate to the admin634ewutrx1jgitlooaj folder and disclose the PrestaShop version installed (8.1.5).

Look for vulnerabilities here: https://www.cvedetails.com/cve/CVE-2024-34716/, and a PoC is available here: https://github.com/aelmokhtar/CVE-2024-34716
If we run it we see it relies on ncat binary, so you may need to make a minor modification to use it with nc or whatever other tool.
The source code modified to use with nc is this.
It provides a reverse shell as user www-data

Under www-data permissions are usually restricted, a good idea is always to find credentials in PHP configuration files.
Use ps_employee credentials to login into MySQL prestashop database. For this you need to have a full interactive shell first.

Now you can connect to database and dump the hashes.
Crack james hash (module 3200), then SSH in and collect the user flag.

ROOT
Start from shell as user james and take the opportunity to enumerate the user and the system.
Enumerate the network config, another docker0 network interface shows up.
Now upload a copy of nmap64 (standalone binary or source code) and scan the 172.17.0.0/24 network.

A host with IP address 172.17.0.2 shows up. Let's launch a port scan on it.

Port 5000 appears open. We need a local port forwarding, using the compromised host as a pivot, to reach this port.
Once the port is forwarded it is possible to browse the site locally with Firefox, use the james password to login.

A changedetection.io web page appears. This application allows the user to track changes in websites, it can monitor modifications on web sites and send a notification. It is useful for being notified on changes for news articles, product updates, or any other online content. And also it seems certain versions are vulnerable to SSTI: https://www.cvedetails.com/cve/CVE-2024-32651/. A PoC for this vulnerability is available here:https://blog.hacktivesecurity.com/index.php/2024/05/08/cve-2024-32651-server-side-template-injection-changedetection-io/
Let's follow the indicated procedure. First check with nuclei if the application is vulnerable. Download the template here:https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2024/CVE-2024-32651.yaml
Then run it with nuclei
The application is found vulnerable.

If you analyze the template, it just checks the value of right-sticky tag in the web site root source code and compares it with the actual vulnerable version.

Once the vulnerability is confirmed, let's proceed exploiting it.
Start a local server to capture the application requests, then enter our own machine IP in the detection menu and click "Watch" to add it.

Click on "Edit" to configure the detection watch. First we configure the frequency we want our server checked.

Next we click on "Notifications" tab, enter the URL to be used for the reports in the format gets://10.10.xxx.xxx, and our favorite jinja2-based SSTI reverse shell payload.
This payload worked.
Click on "Save", we notice an initial request is received on our local HTTP server. The application is requesting the index.html file and starting to detect modifications.
It will check and notify every 30 seconds for changes in the index.html page. To send the reverse shell we have to make changes in the index.html file served on our local HTTP server and wait some seconds till the application detects the change and executes the payload (or just click on "Recheck" if we don't want to wait).
When the application notices the web site has changed, a request is received on our HTTP server and then a reverse shell is received on port 1919.

The web application is being run in a container, meaning you have root shell in the container (172.17.0.2), not in the Trickster machine (172.17.0.1).
Looking for ways to escape the container or move laterally, we find database backups in the path /datastore/Backups/. We find two ZIP files: /changedetection-backup-20240830202524.zip and /changedetection-backup-20240830194841.zip
Let's transfer them outside of the container (172.17.0.2) towards the james SSH shell (172.17.0.1). Start a listener on port 7000 on james shell, then send the files from the container.
The files are received on james shell.

Inside the ZIP files we find two .txt.br files which are files compressed with brotli https://fileinfo.com/extension/br
Install brotli and uncompress the files.
We retrieve a TXT file that contains adam database credentials.
Which we can use to have an SSH session as him, then enumerate his sudo configuration.

Looking for information about this prusaslicer binary, we find a recent RCE exploit available here: https://www.exploit-db.com/exploits/51983 where the vulnerability is explained. Basically you can add a post-process script that will be executed after the binary is run.
Copy the file /opt/PrusaSlicer/TRICKSTER.3mf to your machine and extract with 7z.
Edit the Slic3r_PE.config file in the Metadata directory as indicated in the exploit description (find the post_process line). Add your favorite payload that you want to be executed as root when the tool is run.
Also update the output_filename line because otherwise when the prusaslicer application is run an error related to this line is reported.
Zip again all the package, no compression, then rename to .3mf extension.
Transfer the resulting .3mf to the box again with scp, then run the prusaslicer application.
After the process finishes, verify the SUID bash binary has been created in the /var/tmp directory, then just spawn a root shell.

You are root.
Last updated