Add Failed Hosts Counter

This commit is contained in:
Narbeh 2018-04-17 19:59:43 +04:30
parent 942d3482a0
commit 8993387ad9

View File

@ -28,7 +28,7 @@ def get_cert(host):
try: try:
sock.connect((host, 443)) sock.connect((host, 443))
print('\t{}[+]{} --> {}'.format(TextColor.GREEN, TextColor.RESET, host)) print('\t{}[+]{} {}'.format(TextColor.GREEN, TextColor.RESET, host))
except Exception as e: except Exception as e:
print('\t{}[-]{} {} failed: {}'.format(TextColor.RED, TextColor.RESET, host, e)) print('\t{}[-]{} {} failed: {}'.format(TextColor.RED, TextColor.RESET, host, e))
return None return None
@ -70,13 +70,17 @@ def get_cert_info(cert):
def show_result(hosts): def show_result(hosts):
"""Get the context.""" """Get the context."""
context = {} context, failed_cnt = {}, 0
print('Analyzing {} hosts:\n'.format(len(hosts))) print('Analyzing {} hosts:\n'.format(len(hosts)))
for host in hosts: for host in hosts:
host = clean_hostname(host) host = clean_hostname(host)
cert = get_cert(host) cert = get_cert(host)
if cert: if cert:
context[host] = get_cert_info(cert) context[host] = get_cert_info(cert)
else:
failed_cnt += 1
print('\n{} successful and {} failed.'.format(len(hosts), failed_cnt))
print(context) print(context)