From f614505c964ef7b89cb4ecad736a63fbedeaf6d9 Mon Sep 17 00:00:00 2001 From: Justin Bollinger Date: Tue, 5 May 2026 17:47:52 -0400 Subject: [PATCH] fix(hashview-download): append found hashes to left file, fix rsplit for NTLMv2 --- hate_crack/api.py | 8 +++++++- tests/test_hashview.py | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hate_crack/api.py b/hate_crack/api.py index f40121b..42bf757 100644 --- a/hate_crack/api.py +++ b/hate_crack/api.py @@ -1428,7 +1428,7 @@ class HashviewAPI: for line in f: line = line.strip() if line: - parts = line.split(":", 1) # Split on first colon + parts = line.rsplit(":", 1) if len(parts) == 2: hash_part, clear_part = parts hf.write(hash_part + "\n") @@ -1436,6 +1436,12 @@ class HashviewAPI: hashes_count += 1 clears_count += 1 + # Append found hashes to the left file to reconstruct the full hashlist + with open(output_abs, "a", encoding="utf-8") as lf: + with open(found_hashes_file, "r", encoding="utf-8") as hf: + for line in hf: + lf.write(line) + print( f"Split found file into {hashes_count} hashes and {clears_count} clears" ) diff --git a/tests/test_hashview.py b/tests/test_hashview.py index ed01f2a..0e346e6 100644 --- a/tests/test_hashview.py +++ b/tests/test_hashview.py @@ -644,14 +644,14 @@ class TestHashviewAPI: # Verify left file was created assert os.path.exists(result["output_file"]) - # Verify left file contains only the original uncracked hashes + # Verify left file contains the full original hashlist (left + found) with open(result["output_file"], "r") as f: left_contents = f.read() - assert "found_hash1" not in left_contents, ( - "Found hashes must NOT be written back into the left file" + assert "found_hash1" in left_contents, ( + "Found hashes must be appended to the left file to reconstruct the full hashlist" ) - assert "found_hash2" not in left_contents, ( - "Found hashes must NOT be written back into the left file" + assert "found_hash2" in left_contents, ( + "Found hashes must be appended to the left file to reconstruct the full hashlist" ) assert "uncracked_hash1" in left_contents assert "uncracked_hash2" in left_contents