I came across this Python script that tests the server for the HeartBleed vulnerability:
Would someone be able to explain the content of the "hello", what is being sent and how was this content constructed?
I am not trying to use this script maliciously. I was asked to test a Tomcat 7.0.2 server for the vulnerability: I verified that tcnative-1.dll does use openssl 1.0.1d, but a few of the standalone test tools that I tried testing the server with report that it is not vulnerable.
This page explained a lot about that.
hello
andhb
define bytestrings in a more readable fashion.The
h2bin(x)
function does all the work:so the string of hex digits has all whitespace removed, then is decoded from hex to bytes:
It's just a compact way to specify a series of bytes using hexadecimal notation and extra whitespace.
The hex data itself is just a normal heartbeat protocol message, in raw bytes. The
hello
string contains a TLS 1.1 record message, identified by the first byte (16
hex, 22 decimal) as a handshake record, sending aclient_hello
(sixth byte is01
). This is just setting up a TLS session, telling the server what kind of ciphers the client supports. It doesn't really matter what's contained in this, other than that it tells the server the client supports the Heartbeat extension (a00 0f
byte pair at the end of the message).It is the
hb
message that is interesting one, really:18
is the heartbeat content type record,03 02
identifies the TLS 1.1 protocol version. The00 03
denotes how large the payload of the message is; 3 bytes, or all of the second line.The 3 bytes of the message itself consists of the heartbeat type (
01
, or 'request'), and the message length (40 00
, 16384 bytes), followed by no actual message. This causes a broken SSL server to send back a heartbeat response containing 16kb of memory; the non-existing 0-length request message is echoed plus the memory to make up the request length.