TwoMillion
Overview
A Linux machine retired on the very day it launches for celebrating 2M users on the HackTheBox platform.
Reconnaissance
Hostname
We see the hostname 2million.htb in the HTTP response, so that we put it in our hosts file /etc/hosts.
The site is hosted behind an Nginx server, as we can see in the response header Server. Thus we also fuzz the HTTP request Host header, and it seems that there's no other virtual host.
URL Path
We can use devtool console with CSS selectors to find more URL paths to get more knowledge about this Web App.
Also, we use ffuf to find more URL paths:
Register Process
From the pages /invite and /register, we see that a user must have the right invite code to register as a new member.
Invite Code
From the code contained in the functionscript /js/inviteapi.min.js, we see that we can get the invite code by calling the functiono makeInviteCode in page /invite.

makeInviteCode defined by a eval function in the script /js/inviteapi.min.js.From the enctype ROT13 hint, we can assume that the data is encrypted by rotating with offset 13. We can then get the plaintext by the following Python script:
Then we get the procedure to generate the invite code:
We can register a new user with the generated invite code now.
Home Page
After login successfully, we can see the classical HackTheBox home page.
Only /home/access, /home/rules, and /home/changelog pages are functional.
We can download .ovpn file using related API /api/v1/user/vpn/generate, but we can't use it with openvpn to establish a VPN session.
API Endpoints
As an authenticated user, we can get a list of API endpoints via the path /api/v1 now:
Among these endpoints, it seems that we can use the /api/v1/admin/settings/update one with our authenticated user.
We shall inspect all the endpoints to check if authentication broken exists.
After some errors and tries, we figure out the usage of this endpoint and make our user as admin now.
We can authenticate as an admin now.

Initial Access
VPN Generation
As before, being an admin now, we can figure out the parameters needed to use the other endpoint /api/v1/admin/vpn/generate:
Command Injection
The response contains an OpenVPN connection configuration. The configuration is generated via calling an external command, most possibly, in the backend, so it's likely that the endpoint may have a command injection vulnerability.
We can confirm our guess by inserting commands like ping -c 1 <our_ip> or sleep 10, etc.
Reverse Shell
To use the one-line reverse shell written in Python:
We encode our shell script with base64 encode:
Finally, we insert it into the API endpoint to execute a remote command and get our reverse shell back:
Code Review
We can see the cause of the command injection vulnerability in the PHP code /var/www/html/controllers/VPNController.php:
From the file /var/www/html/.env, we found the database credential:
Now we can log in as admin via SSH into the machine with the above credential now.
Privilege Escalation
Enumeration
After some effort, we found a mail file /var/mail/admin for the user admin.
The content suggests kernelthat we may get privilege escalation via a kernerl vulnerability related to the OverlayFS implementation.
Exploit
We can find and use the following exploit to get the root account.
Last updated