From f6df0e164cd804d2f724e45fa28643f811432366 Mon Sep 17 00:00:00 2001 From: Rafa Faura Date: Sat, 18 Nov 2023 17:55:34 +0100 Subject: [PATCH] Minor: Improve TLS/SSL checks: Allowing testssl.sh to check the URI and display the associated errors. --- README.md | 2 +- humble.py | 30 +++++++++++++++--------------- i10n/details.txt | 5 +---- i10n/details_es.txt | 5 +---- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 7bcbb45..c001c90 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ - + diff --git a/humble.py b/humble.py index e5611b9..afd4a9e 100644 --- a/humble.py +++ b/humble.py @@ -40,7 +40,6 @@ from fpdf import FPDF from time import time from datetime import datetime -from urllib.parse import urlparse from os import linesep, path, remove from colorama import Fore, Style, init from collections import Counter, defaultdict @@ -85,7 +84,7 @@ export_date = datetime.now().strftime("%Y%m%d") now = datetime.now().strftime("%Y/%m/%d - %H:%M:%S") -version = datetime.strptime('2023-11-17', '%Y-%m-%d').date() +version = datetime.strptime('2023-11-18', '%Y-%m-%d').date() class PDF(FPDF): @@ -293,21 +292,10 @@ def testssl_params(directory, uri): testssl_file = path.join(directory, 'testssl.sh') if not path.isfile(testssl_file): sys.exit(f"\n{get_detail('[notestssl_path]')}") - elif not testsst_check_uri(uri): - print("") - sys.exit(get_detail('[kotestssl_uri]')) else: testssl_analysis(testssl_file, uri) -def testsst_check_uri(uri): - try: - parsed_uri = urlparse(uri) - return all([parsed_uri.scheme, parsed_uri.netloc]) - except ValueError: - return False - - def testssl_analysis(testssl_file, uri): # Check './testssl.sh --help' to choose your preferred options: # -p: checks TLS/SSL protocols (including SPDY/HTTP2) @@ -319,13 +307,25 @@ def testssl_analysis(testssl_file, uri): process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - for line in iter(process.stdout.readline, ''): + while True: + line = process.stdout.readline() + if not line: + break print(line, end='') + if 'Done' in line: process.terminate() + process.wait() sys.exit() + + stdout, stderr = process.communicate() + + if stdout: + print(stdout) + if stderr: + print(stderr) except subprocess.CalledProcessError as e: - print(f"Command stderr: {e.stderr}") + print(e.stderr) except Exception as e: print(f"Error running testssl analysis!: {e}") diff --git a/i10n/details.txt b/i10n/details.txt index b1dcdb6..cae210d 100644 --- a/i10n/details.txt +++ b/i10n/details.txt @@ -1160,7 +1160,4 @@ Windows is excluded in this analysis (it should work with Cygwin//MSYS2/WSL but '-o json' currently requires '-b'. [notestssl_path] -Error: 'testssl.sh' is not found in that PATH. - -[kotestssl_uri] -Error: The URL may be incorrect; please check it. \ No newline at end of file +Error: 'testssl.sh' is not found in that PATH. \ No newline at end of file diff --git a/i10n/details_es.txt b/i10n/details_es.txt index 057af36..78e9e1e 100644 --- a/i10n/details_es.txt +++ b/i10n/details_es.txt @@ -1160,7 +1160,4 @@ Windows está excluido en este análisis (debería funcionar con Cygwin//MSYS2/W '-o json' requiere, por ahora, '-b'. [notestssl_path] -Error: no ha encontrado 'testssl.sh' en esa ruta. - -[kotestssl_uri] -Error: La URL puede ser incorrecta; por favor, revísala. \ No newline at end of file +Error: no ha encontrado 'testssl.sh' en esa ruta. \ No newline at end of file