root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat heartbleed.md
// Offensive

HeartBleed

18 Nov 2026 · 4 min read
Executive summary — HeartBleed is an Easy Linux challenge built around CVE-2014-0160, the OpenSSL Heartbeat bug. An HTTPS service on nginx runs a vulnerable OpenSSL; an Nmap script confirms it, and a Metasploit scanner (or a public Python PoC) reads server memory in which a previous visitor's form submission, containing the flag, is still sitting. A Scan → Confirm → Leak memory → Flag journey with no shell involved.
PlatformTryHackMe
Operating systemLinux
DifficultyEasy
RoomHeartBleed
Target IPMACHINE_IP

Attack map

[443/HTTPS]  nginx 1.15.7 on a self-signed certificate (OpenSSL 1.0.1 era)
   |  nmap --script vuln  ->  ssl-heartbleed: VULNERABLE (CVE-2014-0160)
   v
[EXPLOIT]  malformed Heartbeat request (claimed length > real length)
   |  Metasploit auxiliary/scanner/ssl/openssl_heartbleed
   |  or Exploit-DB 32745 (python2)
   v
[LEAK]  up to 64 KB of process memory per request
   |  an earlier POST body is still in the heap
   v
[LOOT]  user_message=FLAG

Background: the Heartbleed bug

TLS has an optional keep-alive feature, the Heartbeat extension (RFC 6520). A client sends a small payload together with a length field, and the server must echo exactly that payload back. In OpenSSL 1.0.1 through 1.0.1f (and 1.0.2-beta releases) the server trusted the length field and never compared it with the amount of data actually received. A client could therefore send a 1-byte payload but declare 65,535 bytes, and the server would copy the payload plus up to roughly 64 KB of whatever sat next to it in memory into the reply. OpenSSL 1.0.1g fixed the bug in April 2014.

The leaked bytes come from the process heap, which can hold anything the process handled recently: session cookies, passwords posted to forms, and in the worst case the server's private key. Nothing is logged as an error and no authentication is required, because the heartbeat is processed after the handshake begins.

1. Reconnaissance

nmap -v -sV -sC MACHINE_IP

Version detection and default scripts reveal a small attack surface:

PORT    STATE    SERVICE  VERSION
22/tcp  open     ssh      OpenSSH 7.4 (protocol 2.0)
111/tcp open     rpcbind  2-4 (RPC #100000)
443/tcp open     ssl/http nginx 1.15.7
|_http-title: What are you looking for?
| ssl-cert: Subject: commonName=localhost/organizationName=TryHackMe
| Not valid before: 2019-02-16   Not valid after: 2020-02-16
Analysis: the only web service is HTTPS, using a self-signed, long-expired certificate issued to localhost. That is characteristic of a deliberately vulnerable lab. SMTP, SMB and MSRPC ports appear as filtered, which just means a firewall drops those probes. The room name plus an HTTPS-only service makes Heartbleed the obvious hypothesis to test.

2. Confirming the vulnerability

Nmap ships a dedicated check, ssl-heartbleed, inside the vuln category. It sends a heartbeat with a mismatched length and reports whether memory comes back:

nmap -v -p 443 --script vuln MACHINE_IP
443/tcp open  https
| ssl-heartbleed:
|   VULNERABLE:
|   The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library.
|     State: VULNERABLE
|     Risk factor: High
|     References: CVE-2014-0160

The same run also flags ssl-ccs-injection (CVE-2014-0224), another 2014 OpenSSL flaw that confirms an old library, and a DoS finding for CVE-2011-3192 that targets Apache; since the server is nginx, that last one is most likely a false positive and can be ignored. Scanning only port 443 (-p 443) keeps the heavy script run short, though it can still take a few minutes.

3. Exploitation with Metasploit

The Metasploit scanner module sends the malformed heartbeat and prints the printable parts of the reply:

msfconsole
msf6 > search heartbleed
msf6 > use auxiliary/scanner/ssl/openssl_heartbleed
msf6 auxiliary(scanner/ssl/openssl_heartbleed) > set RHOSTS MACHINE_IP
msf6 auxiliary(scanner/ssl/openssl_heartbleed) > set VERBOSE true
msf6 auxiliary(scanner/ssl/openssl_heartbleed) > run
  • The search lists three modules; the scanner/ssl one is the actual leak against a server. The server/...client_memory one is the reverse case, attacking clients that connect to a malicious server.
  • Default options (port 443, TLS 1.0, LEAK_COUNT 1) work as they are. VERBOSE true is what makes the module print the leaked content.
  • The module can also be pointed at other protocols that use STARTTLS (SMTP, IMAP, POP3, FTP, ...) through TLS_CALLBACK, which matters on real targets.

The module reports a heartbeat response of roughly 43 KB with a leak, then prints it. Most of the output is dots from non-printable bytes, repeated padding, the certificate and a copy of the site's HTML, but near the beginning is a form submission left in memory by an earlier request:

Content-Type: application/x-www-form-urlencoded
user_name=hacker101&user_email=haxor@haxor.com&user_message=FLAG
Analysis: the flag is inside the user_message parameter of a POST body. The server had previously processed that request and the data was still in memory, exactly the way real credentials or session tokens leaked in 2014. The bytes after the POST include a log line and the page's HTML comment about "secret communication pages", which only reinforces that the heap is a mix of unrelated recent activity.

If nothing interesting shows, run the module again: every request returns a different slice of memory. Setting DUMPFILTER to a pattern such as user_message keeps only matching leaks.

4. Alternative: standalone exploit

Without Metasploit, Exploit-DB has several PoCs. searchsploit finds them offline on Kali:

searchsploit heartbleed
searchsploit -m 32745
python2 32745.py MACHINE_IP

Exploit-DB 32745 is a Python 2 script (it uses print as a statement), so running it with python on a modern system raises a SyntaxError and python2 must be called explicitly. The script performs the TLS handshake and sends one heartbeat, then prints a hex and ASCII dump of the 16 KB it receives. In that dump the same user_name=...&user_email=...&user_message= string appears, and the ASCII column shows the flag, FLAG.

Vulnerability summary

PhaseComponentVulnerabilityImpact
Reconnginx on 443Outdated OpenSSL linked into the web serverExposes a known-vulnerable TLS stack
ExploitationOpenSSL HeartbeatCVE-2014-0160 (Heartbleed): missing bounds check on payload lengthRemote, unauthenticated read of up to 64 KB of process memory per request
ImpactProcess heapSensitive request data left in memoryDisclosure of submitted form data, and in real systems of cookies and private keys

Lessons learned

  • Heartbleed is a memory over-read: no code runs on the server, yet secrets leak. Memory-safe handling and bounds checks on attacker-controlled lengths are the root fix.
  • Patch management must include libraries that services are linked against, and daemons must be restarted after an OpenSSL update to load the fixed library.
  • After a Heartbleed exposure, patching is not enough: certificates and private keys must be reissued, and sessions and passwords rotated, because the leak leaves no trace in logs.
  • Offensively, a quick nmap --script ssl-heartbleed against every TLS port (including STARTTLS services) is cheap and should be part of any assessment.
  • Repeating the exploit yields different memory each time; results from a single run can be misleading.