Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server_info = server_tester.perform()
except:
return error_result
synchronous_scanner = SynchronousScanner()
certificate_result = synchronous_scanner.run_scan_command(
server_info, CertificateInfoScanCommand()
)
cipher_result = synchronous_scanner.run_scan_command(
server_info, Tlsv12ScanCommand()
)
ccs_result = synchronous_scanner.run_scan_command(
server_info, OpenSslCcsInjectionScanCommand()
)
heartbleed_result = synchronous_scanner.run_scan_command(
server_info, HeartbleedScanCommand()
)
if certificate_result.leaf_certificate_subject_matches_hostname:
result_map["match"]["result"] = True
for result in certificate_result.as_text():
result_list = [x.strip() for x in result.split(": ")]
if len(result_list) == 2:
result_map["https"]["result"] = True
if result_list[0] == "Public Key Algorithm":
if result_list[1] == "_RSAPublicKey":
mini_length = 2048
if result_list[0] == "Key Size":
if int(result_list[1]) >= mini_length:
result_map["public"]["result"] = True
if result_list[0] == "Signature Algorithm":
def get_ssl_vulnerabilities_command_map():
"""
Get a dictionary that maps strings to commands supported by Sslyze for enumerating SSL-based
vulnerabilities.
:return: A dictionary that maps strings to commands supported by Sslyze for enumerating SSL-based
vulnerabilities.
"""
return {
"fallback_scsv": {
"command": FallbackScsvScanCommand,
"fields": ["supports_fallback_scsv"],
},
"heartbleed": {
"command": HeartbleedScanCommand,
"fields": ["is_vulnerable_to_heartbleed"],
},
"ccs_injection": {
"command": OpenSslCcsInjectionScanCommand,
"fields": ["is_vulnerable_to_ccs_injection"],
},
"session_renegotiation": {
"command": SessionRenegotiationScanCommand,
"fields": ["accepts_client_renegotiation", "supports_secure_renegotiation"],
},
"session_resumption": {
"command": SessionResumptionSupportScanCommand,
"fields": ["is_ticket_resumption_supported"],
},
# TLSv1.2
command = Tlsv12ScanCommand()
scan_result = synchronous_scanner.run_scan_command(server_info, command)
print("Available TLSv1.2 Ciphers:")
for cipher in scan_result.accepted_cipher_list:
print(' {}'.format(cipher.name))
# Certificate information
command = CertificateInfoScanCommand()
scan_result = synchronous_scanner.run_scan_command(server_info, command)
for entry in scan_result.as_text():
print(entry)
# Heartbleed vulnerability info
command = HeartbleedScanCommand()
scan_result = synchronous_scanner.run_scan_command(server_info, command)
for entry in scan_result.as_text():
print(entry)
# HTTP Headers info
command = HttpHeadersScanCommand()
scan_result = synchronous_scanner.run_scan_command(server_info, command)
for entry in scan_result.as_text():
print(entry)
except Exception as e:
self.handle_exception(e, "Error running SSL scan")
pass