Skip to content

Commit 2aa2cb1

Browse files
author
Tod Beardsley
committed
Reimplement a check.
1 parent d40ab03 commit 2aa2cb1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

modules/auxiliary/scanner/ssl/openssl_heartbleed.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class Metasploit3 < Msf::Auxiliary
8383
'FTP' => :tls_ftp
8484
}
8585

86+
# See the discussion at https://github.com/rapid7/metasploit-framework/pull/3252
87+
SAFE_CHECK_MAX_RECORD_LENGTH = (1 << 14)
88+
8689
def initialize
8790
super(
8891
'Name' => 'OpenSSL Heartbeat (Heartbleed) Information Leak',
@@ -148,6 +151,16 @@ def initialize
148151

149152
end
150153

154+
def check_host(ip)
155+
@check_only = true
156+
vprint_status "#{peer} - Checking for Heartbleed exposure"
157+
if bleed
158+
Exploit::CheckCode::Appears
159+
else
160+
Exploit::CheckCode::Safe
161+
end
162+
end
163+
151164
def run
152165
if heartbeat_length > 65535 || heartbeat_length < 0
153166
print_error("HEARTBEAT_LENGTH should be a natural number less than 65536")
@@ -157,8 +170,16 @@ def run
157170
super
158171
end
159172

173+
# If this is merely a check, set to the RFC-defined
174+
# maximum padding length of 2^14. See:
175+
# https://tools.ietf.org/html/rfc6520#section-4
176+
# https://github.com/rapid7/metasploit-framework/pull/3252
160177
def heartbeat_length
161-
datastore["HEARTBEAT_LENGTH"]
178+
if @check_only
179+
SAFE_CHECK_MAX_RECORD_LENGTH
180+
else
181+
datastore["HEARTBEAT_LENGTH"]
182+
end
162183
end
163184

164185
def peer

0 commit comments

Comments
 (0)