root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat codeparttwo.md
// writeups

CodePartTwo

16 Aug 2025 · 12 min read · root access
CodePartTwo - maquina de Hack The Box

Executive summary — CodePartTwo is a Flask app for running JavaScript online that exposes its own source code (and, unintentionally, its production SQLite database) through an unauthenticated /download endpoint. The source reveals the use of js2py, vulnerable to CVE-2024-28397 — a sandbox escape that gives direct RCE despite disable_pyimport(). An MD5 hash leaked in the database is cracked with a wordlist and turns out to be reused on the real SSH account. From there, a sudo NOPASSWD on the npbackup backup tool, combined with its configurable pre-execution hooks in an arbitrary YAML file, gives full control as root.

PlatformHack The Box
Operating systemLinux
DifficultyEasy
StatusRetired
Target IP10.129.232.59

Attack map

[8000] CodePartTwo — /download leaks the source code + SQLite with no authentication
   │  CVE-2024-28397 — js2py sandbox escape at /run_code
   ▼
[RCE]  Command execution as app
   │  MD5 hash in the DB (marco) cracked with rockyou → reused over SSH
   ▼
[SSH]  marco@host
   │  sudo NOPASSWD on npbackup-cli -c <arbitrary config>
   ▼
[ROOT]  pre_exec_commands from the YAML config → root

1. Reconnaissance

nmap -p- --min-rate 5000 -v 10.129.232.59 -oN nmap_ports.txt
PORT     STATE SERVICE
22/tcp   open  ssh
8000/tcp open  http-alt
nmap -p22,8000 -sCV -v 10.129.232.59 -oN nmap_sV.txt
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
8000/tcp open  http    Gunicorn 20.0.4
|_http-title: Welcome to CodePartTwo

Gunicorn confirms a Python (WSGI) application, most likely Flask or Django.

🔒 Clearance required

This content is Root Access only. Everything else on the site — the free tier, the whole public library — stays open.

See Root Access plans

No account? Create one free then upgrade from your console.