Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python
import json
import md5
import sys
import time
from pprint import pprint
def printEndpoints(endpoints):
endpointString = ""
maxEndpoints = 10
for x in range(0, maxEndpoints):
try:
endpointString += "Grade " + str(x + 1) + ": " + endpoints[x]['grade'] + ", "
except IndexError:
endpointString += "Grade " + str(x + 1) + ": " + "NULL" + ", "
return endpointString
with sys.stdin as json_data:
try:
data = json.load(json_data)
except:
print "Error: no JSON data received!"
exit(1)
for site in data:
status_error = site['status']
# status_msg = site['statusMessage']
if status_error != "READY":
print "Site: %s:%s, Status: %s, Grade 1: NULL, Grade 2: NULL, Grade 3: NULL, Grade 4: NULL, Grade 5: NULL, Grade 6: NULL, Grade 7: NULL, Grade 8: NULL, Grade 9: NULL, Grade 10: NULL, Heartbleed: NULL, Poodle: NULL, PoodleTLS: NULL, Freak: NULL, Logjam: NULL, OpenSSL CCS: NULL, RC4 support: NULL, RC4 with modern: NULL" % (
site['host'],
site['port'],
status_error
)
else:
try:
endpoints = site['endpoints']
status = endpoints[0]['statusMessage']
heartbleed = endpoints[0]['details']['heartbleed']
poodle = endpoints[0]['details']['poodle']
poodleTls = endpoints[0]['details']['poodleTls']
freak = endpoints[0]['details']['freak']
logjam = endpoints[0]['details']['logjam']
openSslCcs = endpoints[0]['details']['openSslCcs']
supportsRc4 = endpoints[0]['details']['supportsRc4']
rc4WithModern = endpoints[0]['details']['rc4WithModern']
except IndexError:
endpoints = []
endpoints[0] = ['Grade']
status = 'N/A'
heartbleed = 'N/A'
poodle = 'N/A'
poodleTls = 'N/A'
freak = 'N/A'
logjam = 'N/A'
openSslCcs = 'N/A'
supportsRc4 = 'N/A'
rc4WithModern = 'N/A'
if status == "Unable to connect to server":
print "Site: %s:%s, Status: %s, Grade 1: NULL, Grade 2: NULL, Grade 3: NULL, Grade 4: NULL, Grade 5: NULL, Grade 6: NULL, Grade 7: NULL, Grade 8: NULL, Grade 9: NULL, Grade 10: NULL, Heartbleed: NULL, Poodle: NULL, PoodleTLS: NULL, Freak: NULL, Logjam: NULL, OpenSSL CCS: NULL, RC4 support: NULL, RC4 with modern: NULL" % (
site['host'],
site['port'],
status
)
elif status == "Failed to communicate with the secure server":
print "Site: %s:%s, Status: %s, Grade 1: NULL, Grade 2: NULL, Grade 3: NULL, Grade 4: NULL, Grade 5: NULL, Grade 6: NULL, Grade 7: NULL, Grade 8: NULL, Grade 9: NULL, Grade 10: NULL, Heartbleed: NULL, Poodle: NULL, PoodleTLS: NULL, Freak: NULL, Logjam: NULL, OpenSSL CCS: NULL, RC4 support: NULL, RC4 with modern: NULL" % (
site['host'],
site['port'],
status
)
elif status == "No secure protocols supported":
print "Site: %s:%s, Status: %s, Grade 1: NULL, Grade 2: NULL, Grade 3: NULL, Grade 4: NULL, Grade 5: NULL, Grade 6: NULL, Grade 7: NULL, Grade 8: NULL, Grade 9: NULL, Grade 10: NULL, Heartbleed: NULL, Poodle: NULL, PoodleTLS: NULL, Freak: NULL, Logjam: NULL, OpenSSL CCS: NULL, RC4 support: NULL, RC4 with modern: NULL" % (
site['host'],
site['port'],
status
)
elif status == "Certificate not valid for domain name":
print "Site: %s:%s, Status: %s, Grade 1: NULL, Grade 2: NULL, Grade 3: NULL, Grade 4: NULL, Grade 5: NULL, Grade 6: NULL, Grade 7: NULL, Grade 8: NULL, Grade 9: NULL, Grade 10: NULL, Heartbleed: NULL, Poodle: NULL, PoodleTLS: NULL, Freak: NULL, Logjam: NULL, OpenSSL CCS: NULL, RC4 support: NULL, RC4 with modern: NULL" % (
site['host'],
site['port'],
status
)
else:
print "Site: %s:%s, Status: %s, %s Heartbleed: %s, Poodle: %s, " % (
site['host'],
site['port'],
status,
printEndpoints(endpoints),
heartbleed,
poodle
),
print "PoodleTLS: %s, Freak: %s, Logjam: %s, OpenSSL CCS: %s, RC4 support: %s, RC4 with modern: %s" % (
poodleTls,
freak,
logjam,
openSslCcs,
supportsRc4,
rc4WithModern
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment