Page cover

Chemistry

Synopsis

Chemistry is a easy linux machine created by FisMatHackarrow-up-right. The pymatgen was used for analyzing cif file and is vulnerable to CVE-2024-23346, which gives us the app user shell. The database.db file contains username and hashes. Cracking them gives us the rosa shell. The port 8080 website is using aiohttp server which is vulnerable to CVE-2024-23334 LFI exploit and the id_rsa file is fetched using the LFI and root shell is gained.

OS
Difficulty
Points
Release Date
Retired Date

Linux

Easy

20

19-10-2024

08-03-2025


Enumeration

Nmap

Starting the nmap scan and found ssh and http services running.

nmap -Pn -sC -sV --min-rate=1000 10.10.11.38
Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-28 11:13 GMT
Nmap scan report for 10.10.11.38
Host is up (0.65s latency).
Not shown: 998 closed tcp ports (reset)
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 b6:fc:20:ae:9d:1d:45:1d:0b:ce:d9:d0:20:f2:6f:dc (RSA)
|   256 f1:ae:1c:3e:1d:ea:55:44:6c:2f:f2:56:8d:62:3c:2b (ECDSA)
|_  256 94:42:1b:78:f2:51:87:07:3e:97:26:c9:a2:5c:0a:26 (ED25519)
5000/tcp open  http    Werkzeug httpd 3.0.3 (Python 3.9.5)
|_http-title: Chemistry - Home
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 99.43 seconds

Web - chemistry.htb [ Port 5000 ]

The website provides the service to analyze the CIF [ Crystallographic Information File ].

Registering will give us access to the dashboard where it has a input field to add the CIF file.

It is also providing the example file of .cif file. Downloading and uploading it gives us the below result.


Foothold

Shell - app [ CVE-2024-23346 Exploit ]

Searching the vulnerability for cif file leads us to CVE-2024-23346 arbitrary code execution vulnerability. The PoC is release on github securityarrow-up-right where cif file is analyzedusing pymatgen, which is used for arbitrary code execution.

1

Create the malicious cif file

2

Open the nc listener and upload the file

3

Getting shell as app

Click on View button and we get the reverse shell as app user.


Privilege Escalation

Pillaging - app [ user ]

The instance directory is present in the users home directory which contains the database.db.

Transfering the file using the python3 http server and wget to our system for enumeration.

Pillaging - database.db [ file ]

The database.db is a sqlite3 database and opening it with sqlitebrowser.

The database contains the two tables structure and user. The user table contains the list of users and password which is hashed.

Shell - rosa

1

Importing the user table as .csv file

2

Filtering the username and hash for the file

3

Cracking the hash using hashcat

Using the password unicorniosrosados we can ssh as rosa.

circle-info

The user.txt file contains the user flag 👏

Pillaging - rosa [ user ]

Running netstat reveals many open ports.

Using curl in port 8080, the header shows the aiohttp/3.9.1.

Shell - root [ CVE-2024-23334 exploit ]

The aiohttp 3.9.1 is vulnerable to CVE-2024-23334 LFI and wizarddos has published the github repositoryarrow-up-right which contains the PoC and script to exploit the vulnerability.

1

Git clone the repository

Git clone the repository in local machine because we cannot directly clone it into the rosa 's shell.

Open the python http server and download it using wget.

2

Executing the script

Running the script to get the /root/.ssh/id_rsa file.

3

Getting the root shell

Copy and paste the id_rsa into local machine file, remove the extra space from the private key because it will give the libcrypto error and change the permissions.

circle-info

The root.txt file contains the root flag 🎉

Proof of Concept

The below video provides the PoC of Chemistry machine.

Last updated