From 4b1b14f2fde23a159b7a9aebfb3290e0833d30fe Mon Sep 17 00:00:00 2001 From: Jonathan Claudius Date: Fri, 25 Jan 2019 13:32:40 -0500 Subject: [PATCH] Show how to upgrade classes without touching task right away: --- lib/tlsobs_scan.py | 34 ++++++++++++++++++++++++++++++++++ tests/test_tlsobs_scan.py | 9 +++++++++ 2 files changed, 43 insertions(+) create mode 100644 lib/tlsobs_scan.py create mode 100644 tests/test_tlsobs_scan.py diff --git a/lib/tlsobs_scan.py b/lib/tlsobs_scan.py new file mode 100644 index 0000000..0780a33 --- /dev/null +++ b/lib/tlsobs_scan.py @@ -0,0 +1,34 @@ +from distutils.spawn import find_executable +import logging +import coloredlogs +import subprocess +from lib import utils +from lib.task import Task + +# This looks ugly and unnecessary in all files, +# should implement per module logging +logger = logging.getLogger(__name__) +coloredlogs.install(level='INFO', logger=logger, reconfigure=True, + fmt='[%(hostname)s] %(asctime)s %(levelname)-8s %(message)s', + datefmt="%Y-%m-%d %I:%M:%S %p %Z") + + +class MozillaTLSObservatoryTask(Task): + + def __init__(self, target_obj): + self.tasktarget = target_obj + + def run(self): + if find_executable('tlsobs'): + # Found in path, run the command + logger.info("[+] Running TLS Observatory scan...") + cmd = "tlsobs -r -raw " + self.tasktarget.targetname \ + + " > /app/results/" + self.tasktarget.targetdomain \ + + "/tlsobs_scan.txt" + tlsobs_cmd = utils.sanitise_shell_command(cmd) + p = subprocess.Popen(tlsobs_cmd, stdout=subprocess.PIPE, shell=True) + p.wait() + return p + else: + logger.error("[-] TLS Observatory not found in Docker image!") + return False diff --git a/tests/test_tlsobs_scan.py b/tests/test_tlsobs_scan.py new file mode 100644 index 0000000..282413f --- /dev/null +++ b/tests/test_tlsobs_scan.py @@ -0,0 +1,9 @@ +from distutils.spawn import find_executable +import logging +import coloredlogs +import subprocess +from lib import utils +from lib.task import Task +from lib.tlsobs_scan import MozillaTLSObservatoryTask + +# ADD THE TESTS FOR TLSOBS SCAN