summaryrefslogtreecommitdiff
path: root/app-crypt/hashcat/hashcat-9999.ebuild
blob: e58c825b4b113abd64b764efdd9b746c290f1d16 (plain)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
	aho-corasick@1.1.3
	bindgen@0.72.1
	bitflags@2.9.2
	block-buffer@0.10.4
	cexpr@0.6.0
	cfg-if@1.0.1
	clang-sys@1.8.1
	cpufeatures@0.2.17
	crypto-common@0.1.6
	digest@0.10.7
	either@1.15.0
	generic-array@0.14.7
	glob@0.3.3
	hex@0.4.3
	itertools@0.13.0
	libc@0.2.175
	libloading@0.8.8
	log@0.4.27
	memchr@2.7.5
	minimal-lexical@0.2.1
	nom@7.1.3
	prettyplease@0.2.37
	proc-macro2@1.0.101
	quote@1.0.40
	regex-automata@0.4.9
	regex-syntax@0.8.5
	regex@1.11.1
	rustc-hash@2.1.1
	sha2@0.10.9
	shlex@1.3.0
	syn@2.0.106
	typenum@1.18.0
	unicode-ident@1.0.18
	version_check@0.9.5
	windows-link@0.1.3
	windows-targets@0.53.3
	windows_aarch64_gnullvm@0.53.0
	windows_aarch64_msvc@0.53.0
	windows_i686_gnu@0.53.0
	windows_i686_gnullvm@0.53.0
	windows_i686_msvc@0.53.0
	windows_x86_64_gnu@0.53.0
	windows_x86_64_gnullvm@0.53.0
	windows_x86_64_msvc@0.53.0
	aho-corasick@1.1.3
	base64@0.22.1
	bcrypt@0.17.1
	bindgen@0.72.1
	bitflags@2.9.3
	block-buffer@0.10.4
	blowfish@0.9.1
	byteorder@1.5.0
	cexpr@0.6.0
	cfg-if@1.0.3
	cipher@0.4.4
	clang-sys@1.8.1
	cpufeatures@0.2.17
	crypto-common@0.1.6
	digest@0.10.7
	either@1.15.0
	generic-array@0.14.7
	getrandom@0.3.3
	glob@0.3.3
	hex@0.4.3
	hmac@0.12.1
	inout@0.1.4
	itertools@0.13.0
	keccak@0.1.5
	libc@0.2.175
	libloading@0.8.8
	log@0.4.27
	md-5@0.10.6
	md2@0.10.2
	md4@0.10.2
	memchr@2.7.5
	minimal-lexical@0.2.1
	nom@7.1.3
	pbkdf2@0.12.2
	prettyplease@0.2.37
	proc-macro2@1.0.101
	quote@1.0.40
	r-efi@5.3.0
	regex-automata@0.4.10
	regex-syntax@0.8.6
	regex@1.11.2
	rustc-hash@2.1.1
	sha1@0.10.6
	sha2@0.10.9
	sha3@0.10.8
	shlex@1.3.0
	subtle@2.6.1
	syn@2.0.106
	thread_local@1.1.9
	typenum@1.18.0
	unicode-ident@1.0.18
	version_check@0.9.5
	wasi@0.14.2+wasi-0.2.4
	windows-link@0.1.3
	windows-targets@0.53.3
	windows_aarch64_gnullvm@0.53.0
	windows_aarch64_msvc@0.53.0
	windows_i686_gnu@0.53.0
	windows_i686_gnullvm@0.53.0
	windows_i686_msvc@0.53.0
	windows_x86_64_gnu@0.53.0
	windows_x86_64_gnullvm@0.53.0
	windows_x86_64_msvc@0.53.0
	wit-bindgen-rt@0.39.0
	zeroize@1.8.1
"

inherit pax-utils toolchain-funcs cargo

DESCRIPTION="World's fastest and most advanced password recovery utility"
HOMEPAGE="https://github.com/hashcat/hashcat"
if [[ ${PV} == "9999" ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/hashcat/hashcat.git"
	SRC_URI="${CARGO_CRATE_URIS}"

else
	KEYWORDS="~amd64"
	SRC_URI="https://github.com/hashcat/hashcat/archive/v${PV}.tar.gz -> ${P}.tar.gz
		${CARGO_CRATE_URIS}"
fi

LICENSE="MIT"
SLOT="0"
IUSE="brain video_cards_nvidia"
RESTRICT=test

DEPEND="app-arch/lzma
	app-arch/unrar
	virtual/minizip:=
	brain? ( dev-libs/xxhash )
	video_cards_nvidia? (
		>x11-drivers/nvidia-drivers-440.64
		|| (
			dev-util/nvidia-cuda-toolkit
			virtual/opencl
		)
	)
	!video_cards_nvidia? ( virtual/opencl )"
RDEPEND="${DEPEND}"

src_unpack() {
	if [[ ${PV} == "9999" ]]; then
		git-r3_src_unpack
	else
		default
	fi
	cargo_src_unpack
}

src_prepare() {
	# Remove bundled stuff
	rm -r deps/OpenCL-Headers || die "Failed to remove bundled OpenCL Headers"
	rm -r deps/xxHash || die "Failed to remove bundled xxHash"

	# TODO: Gentoo's app-arch/lzma doesn't install the needed files
	#rm -r deps/LZMA-SDK || die "Failed to remove bundled LZMA-SDK"
	#rm -r deps || die "Failed to remove bundled deps"

	# Do not strip
	sed -i "/LFLAGS                  += -s/d" src/Makefile || die

	# Do not add random CFLAGS
	sed -i "s/-O2//" src/Makefile || die

	#sed -i "#LZMA_SDK_INCLUDE#d" src/Makefile || die

	# Respect CC, CXX, AR
	sed -i \
		-e 's/:= gcc/:= $(CC)/' \
		-e 's/:= g++/:= $(CXX)/' \
		-e 's/:= ar/:= $(AR)/' \
		src/Makefile || die

	export PREFIX="${EPREFIX}"/usr
	export LIBRARY_FOLDER="/usr/$(get_libdir)"
	export DOCUMENT_FOLDER="/usr/share/doc/${PF}"

	default

	if [[ ${PV} == "9999" ]]; then
		local rust_projects=(
			"Rust/hashcat-sys"
			"Rust/bridges/dynamic_hash"
			"Rust/bridges/generic_hash"
		)
	else
		local rust_projects=(
			"Rust/generic_hash"
		)

	fi

	local proj
	for proj in "${rust_projects[@]}"; do
		if [[ -d "${S}/${proj}" ]]; then
			einfo "Configuring offline Cargo for: ${proj}"
			pushd "${S}/${proj}" > /dev/null || die
			cargo_gen_config
			popd > /dev/null || die
		fi
	done
}

src_compile() {
	tc-export CC CXX AR

	# Use bundled unrar for now, bug #792720
	emake \
		SHARED=1 \
		PRODUCTION=1 \
		ENABLE_BRAIN=$(usex brain 1 0) \
		USE_SYSTEM_LZMA=0 \
		USE_SYSTEM_OPENCL=1 \
		USE_SYSTEM_UNRAR=0 \
		USE_SYSTEM_ZLIB=1 \
		USE_SYSTEM_XXHASH=1 \
		VERSION_PURE="${PV}"

	pax-mark -mr hashcat || die "Failed to apply PaX markings"
}

src_test() {
	if use video_cards_nvidia; then
		addwrite /dev/nvidia0
		addwrite /dev/nvidiactl
		addwrite /dev/nvidia-uvm

		if [[ ! -w /dev/nvidia0 ]]; then
			einfo "To run these tests, portage likely must be in the video group."
			einfo "Please run \"gpasswd -a portage video\" if the tests will fail"
		fi
	fi

	# This always exits with 255 despite success
	#./hashcat -b -m 2500 || die "Test failed"
	LD_PRELOAD=./libhashcat.so.${PV} ./hashcat -a 3 -m 1500 nQCk49SiErOgk || die "Test failed"
}

src_install() {
	emake \
		DESTDIR="${ED}" \
		SHARED=1 \
		PRODUCTION=1 \
		ENABLE_BRAIN=$(usex brain 1 0) \
		USE_SYSTEM_LZMA=0 \
		USE_SYSTEM_OPENCL=1 \
		USE_SYSTEM_UNRAR=1 \
		USE_SYSTEM_ZLIB=1 \
		USE_SYSTEM_XXHASH=1 \
		VERSION_PURE="${PV}" \
		install
}