HTB: Chemistry Walkthru

Enumeration

NMAP

Directory Listing

I think that was a bug, because when I started the mashine again the next day, this directory was gone.

CIF Analyzer

Checking whether simple credentials like admin or admin:password work, but that is not the case.

So, a separate user must be created to access the page.

I tested uploading several files, but only **.CIF files** are allowed.

Exploit

The payload can therefore only be delivered through a **.CIF file**. It took some time and research with Google to find an appropriate method. The correct hint was provided by the following GitHub post:

Arbitrary code execution when parsing a maliciously crafted JonesFaithfulTransformation…

GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to…

The security vulnerability can be exploited as follows, using the example provided on the GitHub page as a reference.

A system command can be executed using the following line:

Example on Github

Using the BuiltinImporter, the built-in module ”os” can be loaded, which is then used to execute commands on the system. In the example, it is utilized to create a file. This approach can be modified to establish a reverse connection.

At the end of the file, the following block must be added:

Foothold

And here is the reverse-shell

Unfortunately, the shell does not have the necessary permissions to read the user flag. Therefore, the privileges must be escalated.

Priv-Escalation

Continue on the CLI. First, perform an upgrade to a TTY shell.

In the instance folder, located in the home directory of the user app, there is a file called database.db.

Check which DBMS is installed on the box.

The file can be opend with sqlite — perfect!

Show all tables in the database

Next, I query the data and output it using standard SQL syntax.

Here, I found users along with their hashes. These are MD5 hashes which can easily be cracked using Hashcat.

One of the passwords is for the user rosa. Accordingly, you can now log in with this user and capture the user flag.

Root-Flag

For a quick overview, Linpeas can be used.

Releases · peass-ng/PEASS-ng

PEASS – Privilege Escalation Awesome Scripts SUITE (with colors) – Releases · peass-ng/PEASS-ng

Simply copy it to the box using python -m http.server.

It looks like there is a vulnerability related to CVE-2021–3560.

GitHub – 0xdevil/CVE-2021-3156: CVE-2021-3156: Sudo heap overflow exploit for Debian 10

CVE-2021-3156: Sudo heap overflow exploit for Debian 10 – 0xdevil/CVE-2021-3156

Unfortunately, this was not confirmed, as the system is not vulnerable to the CVE-2021–3560 vulnerability. No vectors for potential privilege escalation via SUID could be identified either. Therefore, I checked which services are open on the system.

It seems that an application is running on TCP port 8080.

It appears to be some kind of monitoring application running on port 8080.

There seems to be a CVE related to the Python server that can be exploited quite easily.

GitHub – z3rObyte/CVE-2024-23334-PoC: A proof of concept of the path traversal vulnerability in the…

A proof of concept of the path traversal vulnerability in the python AioHTTP library =< 3.9.1 …

LFI-aiohttp-CVE-2024-23334-PoC/lfi_aiohttp.sh at main ·…

Bash script to automate Local File Inclusion (LFI) attacks on aiohttp server version 3.9.1. …

Accordingly, the script from the first GitHub repository can be easily modified, allowing direct access to the root flag.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert