From e736a33eb453a2b36f23b880580986ba37f69b5e Mon Sep 17 00:00:00 2001 From: sein Date: Tue, 10 Nov 2026 11:29:33 +0100 Subject: [PATCH] align hashcat status without the 1 offset fix --- htpclient/generic_cracker.py | 2 +- htpclient/hashcat_cracker.py | 4 ++-- htpclient/hashcat_status.py | 3 ++- tests/test_hashcat_status.py | 6 ++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htpclient/generic_cracker.py b/htpclient/generic_cracker.py index d6acc8e..e251f65 100644 --- a/htpclient/generic_cracker.py +++ b/htpclient/generic_cracker.py @@ -86,7 +86,7 @@ def run_loop(self, process, chunk, task): query['keyspaceProgress'] = chunk['skip'] query['relativeProgress'] = progress query['speed'] = speed - query['state'] = (4 if progress == 10000 else 2) + query['state'] = (5 if progress == 10000 else 3) query['cracks'] = cracks req = JsonRequest(query) diff --git a/htpclient/hashcat_cracker.py b/htpclient/hashcat_cracker.py index 8532f34..2653e0d 100644 --- a/htpclient/hashcat_cracker.py +++ b/htpclient/hashcat_cracker.py @@ -374,7 +374,7 @@ def run_loop(self, proc, chunk, task): query['keyspaceProgress'] = chunk['skip'] query['relativeProgress'] = 0 query['speed'] = 0 - query['state'] = 2 + query['state'] = 3 query['cracks'] = [] req = JsonRequest(query) logging.info("Sending keepalive progress to avoid timeout...") @@ -426,7 +426,7 @@ def run_loop(self, proc, chunk, task): relative_progress = 0 speed = status.get_speed() initial = True - if status.get_state() == 4 or status.get_state() == 5: + if status.get_state() == 5 or status.get_state() == 6: time.sleep(5) # we wait five seconds so all output is loaded from file # reset piping stuff when a chunk is successfully finished self.progressVal = 0 diff --git a/htpclient/hashcat_status.py b/htpclient/hashcat_status.py index 52e4c14..0484d28 100644 --- a/htpclient/hashcat_status.py +++ b/htpclient/hashcat_status.py @@ -97,7 +97,8 @@ def get_progress(self): return self.progress[0] def get_state(self): - return self.status - 1 + """Hashcat's raw status code, kept in sync with the server's DHashcatStatus enum.""" + return self.status def get_curku(self): return self.curku diff --git a/tests/test_hashcat_status.py b/tests/test_hashcat_status.py index 262cc77..a091f0e 100644 --- a/tests/test_hashcat_status.py +++ b/tests/test_hashcat_status.py @@ -115,5 +115,11 @@ def test_get_util(self): status = HashcatStatus(line) self.assertEqual(status.get_util(), (85 + 90) // 2) + def test_get_state_returns_raw_hashcat_status(self): + """get_state() returns hashcat's raw status code, matching the server's DHashcatStatus enum.""" + for state in (0, 1, 2, 3, 5, 6, 7, 11, 13, 14, 16): + status = HashcatStatus(f"STATUS\t{state}\tSPEED\t1000\t1000") + self.assertEqual(status.get_state(), state) + if __name__ == '__main__': unittest.main()