diff --git a/htpclient/hashcat_cracker.py b/htpclient/hashcat_cracker.py index 06f900b..b01bb38 100644 --- a/htpclient/hashcat_cracker.py +++ b/htpclient/hashcat_cracker.py @@ -316,6 +316,10 @@ def run_loop(self, proc, chunk, task): else: identifier, line = item if identifier == 'OUT': + # "7.1.2" -> (7,1,2) + # "7.1.2-546-gc885beef" -> (7,1,2,546) + version_list = self.version_string.replace('-', '.').split('.')[:4] # Chop off anything past the fourth field (for example commit hash) + version_tuple = tuple(int(s) for s in version_list) status = HashcatStatus(line.decode()) if status.is_valid(): self.statusCount += 1 @@ -344,7 +348,12 @@ def run_loop(self, proc, chunk, task): # we need to calculate the chunk start, because progress does not start at 0 for a chunk chunk_start = int(status.get_progress_total() / (chunk['skip'] + chunk['length']) * chunk['skip']) if total > 0: - relative_progress = int((status.get_progress() - chunk_start) / float(total - chunk_start) * 10000) + if version_tuple >= (7, 1, 2, 546): + relative_progress = int(status.get_progress() / total * 10000) + else: + # before hashcat 7.1.2-546, the PROGRESS fields included the skip value. + # Adjust for this offset + relative_progress = int((status.get_progress() - chunk_start) / float(total - chunk_start) * 10000) else: # this is the case when we cannot say anything about the progress relative_progress = 0 speed = status.get_speed()