nixpkgs/pkgs/tools/security/hashcat/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
2.1 KiB
Nix
Raw Normal View History

{ lib, stdenv
, addOpenGLRunpath
, config
, cudaPackages ? {}
, cudaSupport ? config.cudaSupport
2020-06-19 10:36:08 +00:00
, fetchurl
, makeWrapper
, opencl-headers
, ocl-icd
, xxHash
2023-07-19 09:07:08 +00:00
, Foundation, IOKit, Metal, OpenCL, libiconv
2020-06-19 10:36:08 +00:00
}:
stdenv.mkDerivation rec {
2019-05-28 08:51:43 +00:00
pname = "hashcat";
2022-09-06 08:52:49 +00:00
version = "6.2.6";
src = fetchurl {
url = "https://hashcat.net/files/hashcat-${version}.tar.gz";
2022-09-06 08:52:49 +00:00
sha256 = "sha256-sl4Qd7zzSQjMjxjBppouyYsEeyy88PURRNzzuh4Leyo=";
};
2023-07-19 09:07:08 +00:00
postPatch = ''
# Remove hardcoded paths on darwin
substituteInPlace src/Makefile \
--replace "/usr/bin/ar" "ar" \
--replace "/usr/bin/sed" "sed" \
--replace '-i ""' '-i'
'';
nativeBuildInputs = [
makeWrapper
] ++ lib.optionals cudaSupport [
addOpenGLRunpath
];
2023-07-19 09:07:08 +00:00
buildInputs = [ opencl-headers xxHash ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation IOKit Metal OpenCL libiconv ];
makeFlags = [
2019-01-08 02:51:22 +00:00
"PREFIX=${placeholder "out"}"
"COMPTIME=1337"
"VERSION_TAG=${version}"
2019-05-28 08:51:43 +00:00
"USE_SYSTEM_OPENCL=1"
"USE_SYSTEM_XXHASH=1"
];
2023-07-19 09:07:08 +00:00
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.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
'';
meta = with lib; {
description = "Fast password cracker";
homepage = "https://hashcat.net/hashcat/";
license = licenses.mit;
2023-07-19 09:07:08 +00:00
platforms = platforms.unix;
maintainers = with maintainers; [ kierdavis zimbatm ];
};
}