HackTheBox Academy
Table of Contents
Academy from HackTheBox was relatively an easy and straightforward machine, it starts with two open ports SSH on 22 and HTTP on 80 we find an app we abuse the registration system to gain admin access to it then we discover subdomain which is a development server full of information, from there we get a shell on the box, after that we find many users and some credentials around, we try to escalate till we get access to user mrb3n who can use sudo on composer that will give us root access. so let’s start!
Recon #
Nmap #
Nmap full TCP scann shows us 2 open ports.
Looking at the source page revealed nothing so let’s check the links on the page.
Gobuster #
Fuzzing directories got few hits admin.php config.php
Burpsuite #
Looking at registration post request in burpsuite we notice roleid=0 which i can assume it decides if user will be regular or admin account so let’s change that to 1 and see what happens.
User shell #
We set up nc listener on port 9000 and execute the python script with reverse shell to us and we get hit back.
Root shell #
We are logged in as mrb3n and we discovered after typing this command sudo -l that this user can use sudo on composer.
mrb3n@academy:~$ TF=$(mktemp -d)
mrb3n@academy:~$ nano $TF/composer.json
{"scripts":{"rekkodo":"echo ' public key ' >> /root/.ssh/authorized_keys"}}
mrb3n@academy:~$ sudo /usr/bin/composer --working-dir=$TF run-script rekkodo
From our attacking machine we use our private key to login as root.
yami@sama:~$ ssh -i .ssh/id-rsa root@academy.htb