fix: compress hcstat2 output with LZMA2 format for hashcat compatibility

Hashcat requires hcstat2 files to be LZMA2-compressed. The hcstat2gen.bin utility outputs uncompressed binary data, so we need to compress the output after generation.

Root cause: Hashcat's source code (mpsp.c) uses hc_lzma2_decompress() to read hcstat2 files. The bundled hashcat.hcstat2 file uses LZMA2 compression (XZ format). hcstat2gen.bin outputs plain hcstat format which hashcat cannot decompress, causing "Could not uncompress data" error.

Fix: After hcstat2gen.bin completes, compress the output file using Python's lzma module with XZ format (LZMA2-based).

Also restore proper subprocess invocation: pass output path as argument to hcstat2gen.bin instead of using stdout redirection.

Tests: All 8 markov E2E tests pass, 479 total tests pass
This commit is contained in:
Justin Bollinger
2026-03-18 19:40:18 -04:00
parent c71d2a5321
commit afb4b279fc
+13
View File
@@ -23,6 +23,7 @@ import time
import argparse
import urllib.request
import urllib.error
import lzma
from types import SimpleNamespace
#!/usr/bin/env python3
@@ -2121,6 +2122,18 @@ def hcatMarkovTrain(source_file, hcatHashFile):
print(f"[!] Output file is empty: {hcstat2_path}")
return False
# Compress the hcstat2 file with LZMA2 (hashcat requires compressed format)
try:
with open(hcstat2_path, "rb") as f_in:
uncompressed_data = f_in.read()
# Use XZ format which is LZMA2-based
compressed_data = lzma.compress(uncompressed_data, format=lzma.FORMAT_XZ, preset=9)
with open(hcstat2_path, "wb") as f_out:
f_out.write(compressed_data)
except Exception as e:
print(f"[!] Failed to compress hcstat2 file: {e}")
return False
return True