mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-07-28 14:47:22 -07:00
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:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user