From afb4b279fc866320a3ffd32d0cdb5246f2273859 Mon Sep 17 00:00:00 2001 From: Justin Bollinger Date: Wed, 18 Mar 2026 19:40:18 -0400 Subject: [PATCH] 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 --- hate_crack/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hate_crack/main.py b/hate_crack/main.py index 0167146..947bdf9 100755 --- a/hate_crack/main.py +++ b/hate_crack/main.py @@ -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