Post

Valentine

Valentine

Recon

I started with an nmap scan. Three ports are open.

PortServiceDetails
22SSHOpenSSH 5.9p1
80HTTPApache 2.2.22
443HTTPSApache 2.2.22

Port 443 is the interesting one. An old Apache with HTTPS can be vulnerable to Heartbleed (CVE-2014-0160), so I checked it with the nmap script.

1
nmap --script ssl-heartbleed -p 443 TARGET

The script says the server is vulnerable.

Foothold

Heartbleed

Heartbleed lets us read random chunks of the server’s memory through the TLS heartbeat. I used the exploit from exploitdb to dump some memory.

1
python2 /usr/share/exploitdb/exploits/multiple/remote/32764.py TARGET

In the leaked memory there is a base64 string. I decoded it.

1
echo aGVhcnRibGVlZGJlbGlldmV0aGVoeXBl | base64 -d
1
heartbleedbelievethehype

This looks like a passphrase for something. I kept it for later.

The SSH key

The web server has a /dev/hype_key file. The content is an RSA private key, but it is written as hex text. I used xxd -r -p to turn the hex back into the real key file.

1
curl http://TARGET/dev/hype_key | xxd -r -p > hype.key

The key is encrypted, so I removed the passphrase with openssl. The passphrase is the one from Heartbleed.

1
openssl rsa -in hype.key -out hype_dec.key

Then I logged in over SSH as hype.

1
2
chmod 600 hype_dec.key
ssh -i hype_dec.key hype@TARGET

User

Once I was in as hype, I could read user.txt.

1
cat user.txt

Root

While looking around the file system, I found /.devs/dev_sess. It is a tmux socket owned by root:hype with the permissions srw-rw----. So our group can use it.

There is also a root tmux session running (PID 1041). Because we can read and write the socket, we can attach to that root session with the -S option.

1
tmux -S /.devs/dev_sess

This drops us straight into a root shell, and from there I read root.txt.