Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
180 lines (163 loc) · 8.06 KB
/
Copy pathMakefile
File metadata and controls
180 lines (163 loc) · 8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
.DEFAULT_GOAL := install
.PHONY: install reinstall update dev-install dev-reinstall clean hashcat-utils submodules submodules-pre test coverage lint check ruff ty
hashcat-utils: submodules
$(MAKE) -C hashcat-utils
submodules:
@# Initialize submodules only when inside a git repo (not in Docker/CI copies)
@if [ -d .git ] && [ -f .gitmodules ] && command -v git >/dev/null 2>&1; then \
git submodule update --init --recursive; \
fi
@$(MAKE) submodules-pre
@if [ -f .gitmodules ] && command -v git >/dev/null 2>&1; then \
for path in $$(git config --file .gitmodules --get-regexp path | awk '{print $$2}'); do \
if [ "$$path" = "princeprocessor" ]; then \
if [ -f "$$path/pp64.bin" ]; then \
echo "[submodules] princeprocessor already built, skipping"; \
else \
$(MAKE) -C "$$path/src" CFLAGS_LINUX64="-W -Wall -std=c99 -O2 -s -DLINUX"; \
if [ -f "$$path/src/pp64.bin" ]; then cp "$$path/src/pp64.bin" "$$path/"; \
elif [ -f "$$path/src/ppAppleArm64.bin" ]; then cp "$$path/src/ppAppleArm64.bin" "$$path/pp64.bin"; fi; \
fi; \
continue; \
fi; \
if [ -f "$$path/Makefile" ] || [ -f "$$path/makefile" ]; then \
if [ "$$path" = "hashcat-utils" ] && [ -f "$$path/bin/expander.bin" ]; then \
echo "[submodules] hashcat-utils already built, skipping"; \
else \
$(MAKE) -C "$$path"; \
fi; \
fi; \
done; \
fi
submodules-pre:
@test -d hashcat-utils || { echo "Error: missing required directory: hashcat-utils"; exit 1; }
@test -d princeprocessor || { echo "Error: missing required directory: princeprocessor"; exit 1; }
@test -d omen || { echo "Warning: missing directory: omen (OMEN attacks will not be available)"; }
@test -d pcfg_cracker || { echo "Warning: missing directory: pcfg_cracker (PCFG attacks will not be available)"; }
@# Generate per-length expander sources (expander8.c..expander36.c) and patch
@# hashcat-utils Makefiles to compile them. Skips if expander8.c already exists.
@for base in hashcat-utils; do \
src="$$base/src/expander.c"; \
test -f "$$src" || continue; \
test -f "$$base/src/expander8.c" && continue; \
for i in $$(seq 8 36); do \
dst="$$base/src/expander$$i.c"; \
if [ ! -f "$$dst" ]; then \
cp "$$src" "$$dst"; \
perl -pi -e "s/#define LEN_MAX 7/#define LEN_MAX $$i/g" "$$dst"; \
fi; \
done; \
mk="$$base/src/Makefile"; \
test -f "$$mk" || continue; \
exp_bins=""; exp_exes=""; \
for i in $$(seq 8 36); do \
exp_bins="$$exp_bins expander$$i.bin"; \
exp_exes="$$exp_exes expander$$i.exe"; \
done; \
EXP_BINS="$$exp_bins" perl -pi -e \
'if(/^native:/ && index($$_, "expander8.bin") < 0){chomp; $$_ .= "$$ENV{EXP_BINS}\n";}' "$$mk"; \
EXP_EXES="$$exp_exes" perl -pi -e \
'if(/^windows:/ && index($$_, "expander8.exe") < 0){chomp; $$_ .= "$$ENV{EXP_EXES}\n";}' "$$mk"; \
perl -0777 -pi -e 's/\n# Auto-added by hate_crack \\(submodules-pre\\)\n.*\z/\n/s' "$$mk"; \
printf '%s\n' '' '# Auto-added by hate_crack (submodules-pre)' 'expander%.bin: src/expander%.c' >> "$$mk"; \
printf '\t%s\n' '$${CC_NATIVE} $${CFLAGS_NATIVE} $${LDFLAGS_NATIVE} -o bin/$$@ $$<' >> "$$mk"; \
printf '%s\n' '' 'expander%.exe: src/expander%.c' >> "$$mk"; \
printf '\t%s\n' '$${CC_WINDOWS} $${CFLAGS_WINDOWS} -o bin/$$@ $$<' >> "$$mk"; \
done
install: submodules
@echo "Installing dependencies..."
@if [ "$(shell uname)" = "Darwin" ]; then \
echo "Detected macOS"; \
xcode-select -p >/dev/null 2>&1 || { \
echo "Xcode Command Line Tools not found. Installing..."; \
xcode-select --install; \
echo "Re-run 'make' after the Xcode CLT installation completes."; \
exit 1; \
}; \
command -v brew >/dev/null 2>&1 || { echo >&2 "Homebrew not found. Please install Homebrew first: https://brew.sh/"; exit 1; }; \
command -v 7z >/dev/null 2>&1 || brew install p7zip; \
command -v transmission-daemon >/dev/null 2>&1 || brew install transmission-cli; \
elif [ -f /etc/debian_version ]; then \
echo "Detected Debian/Ubuntu"; \
command -v gcc >/dev/null 2>&1 || { sudo apt-get update && sudo apt-get install -y build-essential; }; \
NEED_INSTALL=""; \
command -v 7z >/dev/null 2>&1 || NEED_INSTALL="$$NEED_INSTALL p7zip-full"; \
command -v transmission-daemon >/dev/null 2>&1 || NEED_INSTALL="$$NEED_INSTALL transmission-daemon"; \
if [ -n "$$NEED_INSTALL" ]; then \
sudo apt-get update && sudo apt-get install -y $$NEED_INSTALL; \
fi; \
else \
echo "Unsupported OS. Please install dependencies manually."; \
exit 1; \
fi
@command -v uv >/dev/null 2>&1 || { echo "uv not found. Installing uv..."; curl -LsSf https://astral.sh/uv/install.sh | sh; }
@UV_BIN=$$(command -v uv 2>/dev/null || echo "$$HOME/.local/bin/uv"); \
"$$UV_BIN" sync
@mkdir -p "$${XDG_BIN_HOME:-$$HOME/.local/bin}"
@printf '#!/usr/bin/env bash\nset -euo pipefail\nexport HATE_CRACK_ORIG_CWD="$$PWD"\nexec uv run --directory %s python -m hate_crack "$$@"\n' "$(CURDIR)" \
> "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@chmod +x "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@echo "Installed hate_crack shim to $${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
update: submodules
@uv sync
@mkdir -p "$${XDG_BIN_HOME:-$$HOME/.local/bin}"
@printf '#!/usr/bin/env bash\nset -euo pipefail\nexport HATE_CRACK_ORIG_CWD="$$PWD"\nexec uv run --directory %s python -m hate_crack "$$@"\n' "$(CURDIR)" \
> "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@chmod +x "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@echo "Updated hate_crack shim at $${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
reinstall: uninstall install
dev-install:
@echo "Installing project with development dependencies..."
uv sync --group dev
dev-reinstall: uninstall dev-install
clean:
-$(MAKE) -C hashcat-utils clean
-@if [ -f .gitmodules ]; then git submodule deinit -f --all; fi
rm -rf .pytest_cache .ruff_cache build dist *.egg-info
rm -rf ~/.cache/uv
find . -name "__pycache__" -type d -prune -exec rm -rf {} +
test:
@# Auto-set HATE_CRACK_SKIP_INIT when hashcat-utils binaries are not built
@if [ -z "$$HATE_CRACK_SKIP_INIT" ] && [ ! -f hate_crack/hashcat-utils/bin/expander.bin ] && [ ! -f hate_crack/hashcat-utils/bin/expander.app ]; then \
echo "[test] hashcat-utils not built, setting HATE_CRACK_SKIP_INIT=1"; \
export HATE_CRACK_SKIP_INIT=1; \
fi; \
HATE_CRACK_SKIP_INIT=$${HATE_CRACK_SKIP_INIT:-1} uv run pytest -v
coverage:
@if [ -z "$$HATE_CRACK_SKIP_INIT" ] && [ ! -f hate_crack/hashcat-utils/bin/expander.bin ] && [ ! -f hate_crack/hashcat-utils/bin/expander.app ]; then \
echo "[coverage] hashcat-utils not built, setting HATE_CRACK_SKIP_INIT=1"; \
fi; \
HATE_CRACK_SKIP_INIT=$${HATE_CRACK_SKIP_INIT:-1} uv run pytest --cov=hate_crack --cov-report=term-missing
ruff:
uv run ruff check hate_crack tests tools packaging hate_crack.py
uv run ruff format --check hate_crack tests tools packaging hate_crack.py
# ty's scope is deliberately narrower than ruff's: it reports 48 pre-existing
# diagnostics on hate_crack alone, so this target already fails. CI survives
# only because it passes --exit-zero-on-warning, which this does not. Widening
# to tools/ and packaging/ would add 3 more (an unresolved setuptools import and
# two in packaging/pypi-placeholder/verify_placeholder.py) without fixing any of
# the 48. Clearing those is its own piece of work -- do not bundle it into a
# lint-scope change. See issue #237.
ty:
uv run ty check hate_crack
lint: ruff ty
@echo "All linting checks passed"
check: lint
@echo "Code quality checks passed"
uninstall:
@echo "Detecting OS and uninstalling dependencies..."
@bin_home="$${XDG_BIN_HOME:-$$HOME/.local/bin}"; \
rm -f "$$bin_home/hate_crack"
@if [ "$(shell uname)" = "Darwin" ]; then \
echo "Detected macOS"; \
command -v brew >/dev/null 2>&1 || { echo >&2 "Homebrew not found. Please uninstall Homebrew packages manually."; exit 1; }; \
brew uninstall --ignore-dependencies p7zip transmission-cli || true; \
rm -rf ~/.cache/uv; \
elif [ -f /etc/debian_version ]; then \
echo "Detected Debian/Ubuntu"; \
sudo apt-get remove -y p7zip-full transmission-daemon || true; \
rm -rf ~/.cache/uv; \
else \
echo "Unsupported OS. Please uninstall dependencies manually."; \
exit 1; \
fi