fix: use raw LZMA2 stream instead of XZ container for hcstat2 compression

hashcat's Lzma2Decode() expects a raw LZMA2 stream starting with 0xff chunk
headers, not an XZ container format (0xfd 37 7a...). FORMAT_RAW with
FILTER_LZMA2 produces the correct format.
This commit is contained in:
Justin Bollinger
2026-03-18 20:16:42 -04:00
parent 9e774194c9
commit 346ef32f20

View File

@@ -2126,8 +2126,12 @@ def hcatMarkovTrain(source_file, hcatHashFile):
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)
# Use raw LZMA2 stream (not XZ container) - hashcat decodes with Lzma2Decode()
compressed_data = lzma.compress(
uncompressed_data,
format=lzma.FORMAT_RAW,
filters=[{"id": lzma.FILTER_LZMA2, "preset": 9}],
)
with open(hcstat2_path, "wb") as f_out:
f_out.write(compressed_data)
except Exception as e: