From 942d3482a07054403afa7fd3dd0a4a227b65b43f Mon Sep 17 00:00:00 2001 From: Narbeh Date: Tue, 17 Apr 2018 19:43:46 +0430 Subject: [PATCH] Add Text Color Class --- ssl_checker.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ssl_checker.py b/ssl_checker.py index 4c9d76e..10e9dc5 100644 --- a/ssl_checker.py +++ b/ssl_checker.py @@ -12,6 +12,15 @@ except ImportError: sys.exit(1) +class TextColor: + """Text colors.""" + + RED = '\033[31m' + GREEN = '\033[32m' + YELLOW = '\033[33m' + RESET = '\033[39m' + + def get_cert(host): """Connection to the host.""" osobj = SSL.Context(PROTOCOL_TLSv1) @@ -19,8 +28,9 @@ def get_cert(host): try: sock.connect((host, 443)) + print('\t{}[+]{} --> {}'.format(TextColor.GREEN, TextColor.RESET, host)) except Exception as e: - print('[X] {} failed: {}'.format(host, e)) + print('\t{}[-]{} {} failed: {}'.format(TextColor.RED, TextColor.RESET, host, e)) return None oscon = SSL.Connection(osobj, sock) @@ -61,6 +71,7 @@ def get_cert_info(cert): def show_result(hosts): """Get the context.""" context = {} + print('Analyzing {} hosts:\n'.format(len(hosts))) for host in hosts: host = clean_hostname(host) cert = get_cert(host)