Files
hate_crack/hate_crack.py
Justin Bollinger f43bf2c982 feat: add ngramX attack and gzip auto-detection for external binaries
- Add _is_gzipped() magic-byte detector and _wordlist_path() context
  manager that transparently decompresses gzip files to a temp path
- Apply gzip handling to hcatCombinator3 and hcatCombinatorX via
  contextlib.ExitStack so compressed wordlists work without manual prep
- Add hcatNgramX() wrapper using ngramX.bin <corpus> <group_size> piped
  to hashcat, with gzip auto-detection on the corpus file
- Add ngram_attack() handler in attacks.py with tab-autocomplete corpus
  selection and configurable group size (default 3)
- Register attack as menu option 19 in both main.py and hate_crack.py
- Fix wordlist_optimizer.py: .app extension on macOS was wrong, use .bin
- Add tests/test_ngram_gzip.py covering ngram_attack handler, _is_gzipped,
  and _wordlist_path context manager (temp file cleanup, plain passthrough)
2026-03-19 14:35:29 -04:00

110 lines
2.6 KiB
Python
Executable File

#!/usr/bin/env -S uv run --project .
import sys
from hate_crack import main as _main
# Re-export symbols for tests and legacy imports.
for _name, _value in _main.__dict__.items():
if _name.startswith("__") and _name not in {
"__all__",
"__doc__",
"__name__",
"__package__",
"__loader__",
"__spec__",
}:
continue
globals().setdefault(_name, _value)
def __getattr__(name):
return getattr(_main, name)
def _sync_globals_to_main():
# Keep commonly-mutated globals aligned for tests and wrappers.
for name in (
"hcatHashType",
"pipal_count",
"hcatHashFile",
"hcatHashFileOrig",
"pipalPath",
"debug_mode",
):
if name in globals():
setattr(_main, name, globals()[name])
def _sync_callables_to_main():
for name in (
"weakpass_wordlist_menu",
"download_hashmob_wordlists",
"download_hashmob_rules",
"hashview_api",
"export_excel",
"show_results",
"show_readme",
"quit_hc",
):
if name in globals():
setattr(_main, name, globals()[name])
def cli_main():
_sync_globals_to_main()
_sync_callables_to_main()
return _main.main()
def main():
_sync_globals_to_main()
_sync_callables_to_main()
return _main.main()
def pipal():
_sync_globals_to_main()
return _main.pipal()
def get_main_menu_items():
return _main.get_main_menu_items()
def get_main_menu_options():
options = {
"1": _attacks.quick_crack,
"2": _attacks.extensive_crack,
"3": _attacks.brute_force_crack,
"4": _attacks.top_mask_crack,
"5": _attacks.fingerprint_crack,
"6": _attacks.combinator_submenu,
"7": _attacks.hybrid_crack,
"8": _attacks.pathwell_crack,
"9": _attacks.prince_attack,
"13": _attacks.bandrel_method,
"14": _attacks.loopback_attack,
"15": _attacks.ollama_attack,
"16": _attacks.omen_attack,
"17": _attacks.adhoc_mask_crack,
"18": _attacks.markov_brute_force,
"19": _attacks.ngram_attack,
"90": download_hashmob_rules,
"91": weakpass_wordlist_menu,
"92": download_hashmob_wordlists,
"93": weakpass_wordlist_menu,
"95": pipal,
"96": export_excel,
"97": show_results,
"98": show_readme,
"99": quit_hc,
}
# Only show Hashview API when configured.
if globals().get("hashview_api_key"):
options["94"] = hashview_api
return options
if __name__ == "__main__":
sys.exit(main())