HackTheBox Writeup – Academy

Greetings from Macksofy Technologies. Below is the detailed walkthrough of the Passage machine which got retired from HackTheBox

The IP of this box is 10.10.10.215

Running NMAP full port scan on it , we get

Image for post

We have 3 Open Ports , Port 22 , Port 80 and Port 33060 for SSH , Web and MYSQLx respectively

Looking on the Web part of the NMAP scan, we see it is leading to a redirection towards http://academy.htb domain, so I add it to our hosts file and moving towards the Web

Checking the web, we have a webpage where we can see the option for Login and Register

Image for post

Registering a user and then login

Image for post

We get a wonderful webpage which is a clone of the HackTheBox’s new initiative Academy

Image for post

Nothing much in this webpage, so lets check the Gobuster result

Image for post

We found a admin.php page which redirects us to a login page for admins

Image for post

Moving towards the register.php where we registered a new user before and intercepting the request in Burp Suite

Image for post

We see that the parameter uid is for username , password for password and there is an additional parameter roleid which is by default set to 0 , maybe its for the account privileges on which if we change it to 1 might give us admin privileges

Image for post

Sending the request and trying to login on the admin.php page redirects us to admin-page.php where we have a page with planner which has some to-do tasks and one of them is still on pending

Image for post

We see one of the task is to fix the issue on the dev-staging-01.academy.htb domain , adding it to our hosts file and trying to access it

Image for post

Doing some web enumeration on it, we see the Environment Variables which shows the details of the app and it tells us that it is made on Laravel framework

Image for post

Searching on Google for the exploits on Laravel, we have a exploit available on metasploit

Image for post

We set the options for the exploit with the required options

Image for post

Our exploit ran successfully and we got shell as www-data

Image for post

Enumerating the webroot directory, we have a .env file which has a DB_PASSWORD

Image for post

Trying the password for the available users on the machine, we get hit successfully on user cry0l1t3

Image for post

Time for privilege escalation

Unintended Way

As soon as I was logged in through SSH, there was a broadcast message displayed with the password for mrb3n leaking

Image for post

Intended Way

Checking the groups of the current user , it is a group member of adm group

Image for post

Finding files accessible to group members of adm, a lot of logs files were accessible to the current user and interesting ones were the audit log files

Image for post

Checking those log files, we see that there are a lot of encrypted data

Image for post

Decrypting all those data using CyberChef’s Magic decryption leads us to the password for mrb3n account

Image for post

Connecting to the account was successful

Image for post

Running the sudo -l command, the user can run /usr/bin/composer with sudo privileges

Image for post

Taking reference from GTFOBins for this binary helped for getting root

Image for post

References

Insecure direct object references (IDOR) | Web Security Academy

portswigger.net

Offensive Security’s Exploit Database Archive

PHP Laravel Framework 5.5.40 / 5.6.x < 5.6.30 – token Unserialize Remote Command Execution (Metasploit)…

www.exploit-db.com

composer | GTFOBins

It can be used to break out from restricted environments by spawning an interactive system shell.

gtfobins.github.io

Leave a Reply

Your email address will not be published. Required fields are marked *