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
|
{
lib,
stdenv,
addDriverRunpath,
config,
cudaPackages_12_4 ? { },
cudaSupport ? config.cudaSupport,
fetchurl,
makeWrapper,
minizip,
opencl-headers,
ocl-icd,
xxHash,
zlib,
libiconv,
}:
stdenv.mkDerivation rec {
pname = "hashcat";
version = "7.0.0";
src = fetchurl {
url = "https://hashcat.net/files/hashcat-${version}.tar.gz";
sha256 = "sha256-hCtx0NNLAgAFiCR6rp/smg/BMnfyzTpqSSWw8Jszv3U=";
};
postPatch = ''
# MACOSX_DEPLOYMENT_TARGET is defined by the enviroment
# Remove hardcoded paths on darwin
substituteInPlace src/Makefile \
--replace "export MACOSX_DEPLOYMENT_TARGET" "#export MACOSX_DEPLOYMENT_TARGET" \
--replace "/usr/bin/ar" "ar" \
--replace "/usr/bin/sed" "sed" \
--replace '-i ""' '-i'
'';
nativeBuildInputs = [
makeWrapper
]
++ lib.optionals cudaSupport [
addDriverRunpath
];
buildInputs = [
minizip
opencl-headers
xxHash
zlib
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
];
makeFlags = [
"PREFIX=${placeholder "out"}"
"COMPTIME=1337"
"VERSION_TAG=${version}"
"USE_SYSTEM_OPENCL=1"
"USE_SYSTEM_XXHASH=1"
"USE_SYSTEM_ZLIB=1"
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform) [
"IS_APPLE_SILICON='${if stdenv.hostPlatform.isAarch64 then "1" else "0"}'"
]
++ lib.optionals stdenv.hostPlatform.isAarch64 [
"IS_AARCH64=1"
];
enableParallelBuilding = true;
preFixup = ''
for f in $out/share/hashcat/OpenCL/*.cl; do
# Rewrite files to be included for compilation at runtime for opencl offload
sed "s|#include \"\(.*\)\"|#include \"$out/share/hashcat/OpenCL/\1\"|g" -i "$f"
sed "s|#define COMPARE_\([SM]\) \"\(.*\.cl\)\"|#define COMPARE_\1 \"$out/share/hashcat/OpenCL/\2\"|g" -i "$f"
done
'';
postFixup =
let
LD_LIBRARY_PATH = builtins.concatStringsSep ":" (
[
"${ocl-icd}/lib"
]
++ lib.optionals cudaSupport [
"${cudaPackages_12_4.cudatoolkit}/lib"
]
);
in
''
wrapProgram $out/bin/hashcat \
--prefix LD_LIBRARY_PATH : ${lib.escapeShellArg LD_LIBRARY_PATH}
''
+ lib.optionalString cudaSupport ''
for program in $out/bin/hashcat $out/bin/.hashcat-wrapped; do
isELF "$program" || continue
addDriverRunpath "$program"
done
'';
meta = with lib; {
description = "Fast password cracker";
mainProgram = "hashcat";
homepage = "https://hashcat.net/hashcat/";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with maintainers; [
felixalbrigtsen
zimbatm
];
};
}
|