Monitored
Executive summary — Monitored chains a public SNMP community with no view attached that leaks service credentials through the process table, an inconsistent authorization flaw in Nagios XI (the authentication API doesn't check the
enabledflag that the web login does check), and CVE-2023-40931 — a time-based blind SQL injection — to stealnagiosadmin's API key, create an admin user and get RCE by abusing Nagios's own mechanisms (Manage Plugins + Core Config Manager). The final escalation reuses asudorule that starts thenpcddaemon viasystemd— the binary that service executes turns out to be writable by the very user granted thatsudo.
| Platform | Hack The Box |
| Operating system | Linux (Debian 11) |
| Difficulty | Medium |
| Status | Retired |
| Target IP | <TARGET_IP> |
Attack map
[161/UDP] SNMP — "public" rocommunity with no view attached
│ hrSWRunParameters leaks check_host.sh's cmdline:
│ svc : XjH7VCehowpR1xZB
▼
[API] Nagios XI /api/v1/authenticate — does not check the "enabled" flag
│ SSH and the web login reject svc; the API hands it a valid token
▼
[SQLi] CVE-2023-40931 — banner_message-ajaxhelper.php, time-based blind
│ extracts nagiosadmin's API key
▼
[ADMIN] API creates an admin user -> Manage Plugins + CCM (check_local_users)
│ RCE: own SSH key installed in /home/nagios/.ssh
▼
[SSH] nagios (user.txt)
│ sudo NOPASSWD manage_services.sh start npcd -> systemd ExecStart
│ /usr/local/nagios/bin/npcd is writable by nagios
▼
[ROOT] swap npcd for a script -> systemd runs it as root -> SUID bash
1. Reconnaissance
1.1 TCP ports
sudo nmap -p- --min-rate 5000 -T4 -Pn -oN nmap_allports.txt <TARGET_IP>
sudo nmap -p22,80,389,443,5667 -sCV -Pn -oN nmap_services.txt <TARGET_IP>
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u3 (protocol 2.0)
80/tcp open http Apache httpd 2.4.56
|_http-title: Did not follow redirect to https://nagios.monitored.htb/
389/tcp open ldap OpenLDAP 2.2.X - 2.3.X
443/tcp open ssl/http Apache httpd 2.4.56 ((Debian))
|_http-title: Nagios XI
| ssl-cert: Subject: commonName=nagios.monitored.htb/organizationName=Monitored/
| stateOrProvinceName=Dorset/countryName=UK
5667/tcp open tcpwrapped
The TLS certificate reveals the vhost nagios.monitored.htb. Port 5667 is NSCA (Nagios Service Check Acceptor) and 389 is LDAP: all consistent with a Nagios XI install.
echo "<TARGET_IP> monitored.htb nagios.monitored.htb" | sudo tee -a /etc/hosts
1.2 The port that changes the game
With a monitoring server in front of you, UDP has to be scanned. SNMP is the monitoring protocol and lives on 161/udp: a TCP scan would never see it.
sudo nmap -sU --top-ports 50 --min-rate 2000 -Pn -oN nmap_udp.txt <TARGET_IP>
PORT STATE SERVICE
123/udp open ntp
161/udp open snmp
Skipping the UDP scan is the most common mistake on monitoring boxes. Here, without 161, there is no way in.
Root Access unlocks the content you can't see — everything else on the site is already open.
See Root Access plansNo account? Create one free then upgrade from your console.