2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2023-07-15 17:15:38 +00:00
|
|
|
, addOpenGLRunpath
|
|
|
|
, config
|
|
|
|
, cudaPackages ? {}
|
2023-08-04 22:07:22 +00:00
|
|
|
, cudaSupport ? config.cudaSupport
|
2020-06-15 15:56:04 +00:00
|
|
|
, fetchurl
|
|
|
|
, makeWrapper
|
|
|
|
, opencl-headers
|
|
|
|
, ocl-icd
|
|
|
|
, xxHash
|
2023-08-04 22:07:22 +00:00
|
|
|
, Foundation, IOKit, Metal, OpenCL, libiconv
|
2020-06-15 15:56:04 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "hashcat";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "6.2.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://hashcat.net/files/hashcat-${version}.tar.gz";
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256-sl4Qd7zzSQjMjxjBppouyYsEeyy88PURRNzzuh4Leyo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Remove hardcoded paths on darwin
|
|
|
|
substituteInPlace src/Makefile \
|
|
|
|
--replace "/usr/bin/ar" "ar" \
|
|
|
|
--replace "/usr/bin/sed" "sed" \
|
|
|
|
--replace '-i ""' '-i'
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
addOpenGLRunpath
|
|
|
|
];
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
buildInputs = [ opencl-headers xxHash ]
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation IOKit Metal OpenCL libiconv ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=${placeholder "out"}"
|
|
|
|
"COMPTIME=1337"
|
|
|
|
"VERSION_TAG=${version}"
|
|
|
|
"USE_SYSTEM_OPENCL=1"
|
|
|
|
"USE_SYSTEM_XXHASH=1"
|
2023-10-09 19:29:22 +00:00
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform) [
|
|
|
|
"IS_APPLE_SILICON='${if stdenv.hostPlatform.isAarch64 then "1" else "0"}'"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-02-22 21:28:39 +00:00
|
|
|
preFixup = ''
|
|
|
|
for f in $out/share/hashcat/OpenCL/*.cl; do
|
2021-05-20 23:08:51 +00:00
|
|
|
# Rewrite files to be included for compilation at runtime for opencl offload
|
2021-02-22 21:28:39 +00:00
|
|
|
sed "s|#include \"\(.*\)\"|#include \"$out/share/hashcat/OpenCL/\1\"|g" -i "$f"
|
2021-05-20 23:08:51 +00:00
|
|
|
sed "s|#define COMPARE_\([SM]\) \"\(.*\.cl\)\"|#define COMPARE_\1 \"$out/share/hashcat/OpenCL/\2\"|g" -i "$f"
|
2021-02-22 21:28:39 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
postFixup = let
|
|
|
|
LD_LIBRARY_PATH = builtins.concatStringsSep ":" ([
|
|
|
|
"${ocl-icd}/lib"
|
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
"${cudaPackages.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
|
|
|
|
addOpenGLRunpath "$program"
|
|
|
|
done
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Fast password cracker";
|
|
|
|
homepage = "https://hashcat.net/hashcat/";
|
|
|
|
license = licenses.mit;
|
2023-08-04 22:07:22 +00:00
|
|
|
platforms = platforms.unix;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ felixalbrigtsen kierdavis zimbatm ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|