From 11234299268d32da974b9c6700e6758e0028c5b1 Mon Sep 17 00:00:00 2001 From: shivanraptor Date: Wed, 14 Oct 2020 14:13:39 +0800 Subject: [PATCH 1/2] Added native hashcat support in macOS In initialization process, check if Homebrew and hashcat are installed. In Hashcat_Cracker, symlink the native hashcat with the missing "hashcat.osx" --- htpclient/hashcat_cracker.py | 9 +++++++++ htpclient/initialize.py | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/htpclient/hashcat_cracker.py b/htpclient/hashcat_cracker.py index 4b3e512..7b4da1d 100644 --- a/htpclient/hashcat_cracker.py +++ b/htpclient/hashcat_cracker.py @@ -31,6 +31,15 @@ def __init__(self, cracker_id, binary_download): if Initialize.get_os() != 1: self.callPath = "./" + self.callPath + # Symlink hashcat.osx in macOS + if not os.path.isfile(self.cracker_path + "hashcat.osx"): + if Initialize.get_os() == 2: # macOS + try: + output = subprocess.check_output("ln -s $(which hashcat) hashcat.osx", shell=True, cwd=self.cracker_path) + except subprocess.CalledProcessError as e: + logging.error("Error during version detection: " + str(e)) + sleep(5) + if not os.path.isfile(self.cracker_path + self.callPath): # in case it's not the new hashcat filename, try the old one (hashcat.) self.executable_name = binary_download.get_version()['executable'] k = self.executable_name.rfind(".") diff --git a/htpclient/initialize.py b/htpclient/initialize.py index 839b60b..1ea0085 100644 --- a/htpclient/initialize.py +++ b/htpclient/initialize.py @@ -118,6 +118,22 @@ def __update_information(self): devices.append(line) else: # OS X + logging.info("Check if Homebrew is installed...") + output = subprocess.check_output("type brew", shell=True) + output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n") + for line in output: + line = line.rstrip("\r\n ") + if "not found" in line: + log_error_and_exit("Please install Homebrew first. Visit https://brew.sh for instructions.") + + logging.info("Check if hashcat is installed via Homebrew...") + output = subprocess.check_output("brew info hashcat", shell=True) + output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n") + for line in output: + line = line.rstrip("\r\n ") + if line == "Not installed": + log_error_and_exit("Please install hashcat via Homebrew first: brew install hashcat") + output = subprocess.check_output("system_profiler -detaillevel mini", shell=True) output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n") for line in output: From be105b3a674cd90af0c13c42b0ec6e35251882cc Mon Sep 17 00:00:00 2001 From: shivanraptor Date: Wed, 14 Oct 2020 15:28:01 +0800 Subject: [PATCH 2/2] Fixed indentation issues --- htpclient/hashcat_cracker.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htpclient/hashcat_cracker.py b/htpclient/hashcat_cracker.py index 7b4da1d..1a23255 100644 --- a/htpclient/hashcat_cracker.py +++ b/htpclient/hashcat_cracker.py @@ -32,13 +32,13 @@ def __init__(self, cracker_id, binary_download): self.callPath = "./" + self.callPath # Symlink hashcat.osx in macOS - if not os.path.isfile(self.cracker_path + "hashcat.osx"): - if Initialize.get_os() == 2: # macOS - try: - output = subprocess.check_output("ln -s $(which hashcat) hashcat.osx", shell=True, cwd=self.cracker_path) - except subprocess.CalledProcessError as e: - logging.error("Error during version detection: " + str(e)) - sleep(5) + if not os.path.isfile(self.cracker_path + "hashcat.osx"): # in case it's not the + if Initialize.get_os() == 2: # macOS + try: + output = subprocess.check_output("ln -s $(which hashcat) hashcat.osx", shell=True, cwd=self.cracker_path) + except subprocess.CalledProcessError as e: + logging.error("Error during version detection: " + str(e)) + sleep(5) if not os.path.isfile(self.cracker_path + self.callPath): # in case it's not the new hashcat filename, try the old one (hashcat.) self.executable_name = binary_download.get_version()['executable']