fix(hashview-download): append found hashes to left file, fix rsplit for NTLMv2

This commit is contained in:
Justin Bollinger
2026-05-05 17:47:52 -04:00
parent 894a565a7f
commit f614505c96
2 changed files with 12 additions and 6 deletions
+7 -1
View File
@@ -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"
)
+5 -5
View File
@@ -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