2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2023-07-01 08:59:09 +00:00
|
|
|
, addOpenGLRunpath
|
|
|
|
, config
|
|
|
|
, cudaPackages ? {}
|
2023-07-20 15:08:19 +00:00
|
|
|
, 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
|
|
|
}:
|
2014-03-31 15:56:02 +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";
|
2014-03-31 15:56:02 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2017-11-01 15:05:10 +00:00
|
|
|
url = "https://hashcat.net/files/hashcat-${version}.tar.gz";
|
2022-09-06 08:52:49 +00:00
|
|
|
sha256 = "sha256-sl4Qd7zzSQjMjxjBppouyYsEeyy88PURRNzzuh4Leyo=";
|
2014-03-31 15:56:02 +00:00
|
|
|
};
|
|
|
|
|
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'
|
|
|
|
'';
|
|
|
|
|
2023-07-01 08:59:09 +00:00
|
|
|
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 ];
|
2014-03-31 15:56:02 +00:00
|
|
|
|
2017-11-01 15:05:10 +00:00
|
|
|
makeFlags = [
|
2019-01-08 02:51:22 +00:00
|
|
|
"PREFIX=${placeholder "out"}"
|
2017-11-01 15:05:10 +00:00
|
|
|
"COMPTIME=1337"
|
|
|
|
"VERSION_TAG=${version}"
|
2019-05-28 08:51:43 +00:00
|
|
|
"USE_SYSTEM_OPENCL=1"
|
|
|
|
"USE_SYSTEM_XXHASH=1"
|
2017-11-01 15:05:10 +00:00
|
|
|
];
|
2014-03-31 15:56:02 +00:00
|
|
|
|
2023-07-19 09:07:08 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-02-22 01:37:51 +00:00
|
|
|
preFixup = ''
|
|
|
|
for f in $out/share/hashcat/OpenCL/*.cl; do
|
2021-05-11 12:01:35 +00:00
|
|
|
# Rewrite files to be included for compilation at runtime for opencl offload
|
2021-02-22 01:37:51 +00:00
|
|
|
sed "s|#include \"\(.*\)\"|#include \"$out/share/hashcat/OpenCL/\1\"|g" -i "$f"
|
2021-05-11 12:01:35 +00:00
|
|
|
sed "s|#define COMPARE_\([SM]\) \"\(.*\.cl\)\"|#define COMPARE_\1 \"$out/share/hashcat/OpenCL/\2\"|g" -i "$f"
|
2021-02-22 01:37:51 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2023-07-01 08:59:09 +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
|
2014-03-31 15:56:02 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2014-03-31 15:56:02 +00:00
|
|
|
description = "Fast password cracker";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://hashcat.net/hashcat/";
|
2017-11-01 15:05:10 +00:00
|
|
|
license = licenses.mit;
|
2023-07-19 09:07:08 +00:00
|
|
|
platforms = platforms.unix;
|
2017-11-01 15:05:10 +00:00
|
|
|
maintainers = with maintainers; [ kierdavis zimbatm ];
|
2014-03-31 15:56:02 +00:00
|
|
|
};
|
|
|
|
}
|