Enumeration

Nmap

Initial nmap scan revealed HTTP and SSH ports were open.

00 - nmap

Web Enumeration

The web request was forwarded to cozyhosting.htb, so I added it to /etc/hosts file.

01 - website

Then I applied standard directory brute forcing and found an error page.

02 - spring boot error page

Searching this page revealed that this was a spring boot application.

03 - spring boot

Then I applied directory brute forcing with the spring boot specific wordlists and found a valid endpoint named actuator.

04 - dirbuster

This endpoint included some URLs.

05 - urls

The actuator/sessions path contained some valid session cookies.

06 - sessions

Then I passed the session cookie and logged in as the kanderson user.

07 - cookie update and login

Exploit

Command Injection

The wabsite included executessh functionality. At first I tried some command injection methods and it did not work. Later I understood that it was avoiding whitespaces. So I encoded a tab (\t) and it worked. The ${IFS} also works to avoid whitespaces.

08 - command injection

Then I created a reverse shell payload and got a reverse shell.

09 - revshell

After the initial connection, I was in app directory which included a JAR file. I transfered that file to my machine, and unzipped it.

The file was spring boot application’s JAR file. Later, I did some research and found that application.properties file includes some configurations related to the web app. So I checked that file and found a database and its password.

10 - psql infos

Then using ‘psql’ command with the necessary parameteres, I got an interactive PostgreSQL shell. Checking the tables revealed the users table.

11 - sql

And the users table included hashed passwords of users.

12 - passwords

Then I cracked admin hash with hashcat and rockyou.txt wordlist.

13 - cracked

Then used this password to login with SSH and got the user flag.

14 - user flag

Privilege Escalation

The user could run SSH with sudo privileges. The GTFOBins included sudo ssh privilege escalation. I simply applied the necessary steps and got the root.

15 - root

Pwned

The machine was pwned.

pwned


<
Previous Post
Networked - Hack The Box
>
Next Post
BabyTwo - Hack The Box