at 24.05-pre 83 lines 2.4 kB view raw
1{ lib, stdenv 2, addOpenGLRunpath 3, config 4, cudaPackages ? {} 5, cudaSupport ? config.cudaSupport 6, fetchurl 7, makeWrapper 8, opencl-headers 9, ocl-icd 10, xxHash 11, Foundation, IOKit, Metal, OpenCL, libiconv 12}: 13 14stdenv.mkDerivation rec { 15 pname = "hashcat"; 16 version = "6.2.6"; 17 18 src = fetchurl { 19 url = "https://hashcat.net/files/hashcat-${version}.tar.gz"; 20 sha256 = "sha256-sl4Qd7zzSQjMjxjBppouyYsEeyy88PURRNzzuh4Leyo="; 21 }; 22 23 postPatch = '' 24 # Remove hardcoded paths on darwin 25 substituteInPlace src/Makefile \ 26 --replace "/usr/bin/ar" "ar" \ 27 --replace "/usr/bin/sed" "sed" \ 28 --replace '-i ""' '-i' 29 ''; 30 31 nativeBuildInputs = [ 32 makeWrapper 33 ] ++ lib.optionals cudaSupport [ 34 addOpenGLRunpath 35 ]; 36 37 buildInputs = [ opencl-headers xxHash ] 38 ++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation IOKit Metal OpenCL libiconv ]; 39 40 makeFlags = [ 41 "PREFIX=${placeholder "out"}" 42 "COMPTIME=1337" 43 "VERSION_TAG=${version}" 44 "USE_SYSTEM_OPENCL=1" 45 "USE_SYSTEM_XXHASH=1" 46 ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform) [ 47 "IS_APPLE_SILICON='${if stdenv.hostPlatform.isAarch64 then "1" else "0"}'" 48 ]; 49 50 enableParallelBuilding = true; 51 52 preFixup = '' 53 for f in $out/share/hashcat/OpenCL/*.cl; do 54 # Rewrite files to be included for compilation at runtime for opencl offload 55 sed "s|#include \"\(.*\)\"|#include \"$out/share/hashcat/OpenCL/\1\"|g" -i "$f" 56 sed "s|#define COMPARE_\([SM]\) \"\(.*\.cl\)\"|#define COMPARE_\1 \"$out/share/hashcat/OpenCL/\2\"|g" -i "$f" 57 done 58 ''; 59 60 postFixup = let 61 LD_LIBRARY_PATH = builtins.concatStringsSep ":" ([ 62 "${ocl-icd}/lib" 63 ] ++ lib.optionals cudaSupport [ 64 "${cudaPackages.cudatoolkit}/lib" 65 ]); 66 in '' 67 wrapProgram $out/bin/hashcat \ 68 --prefix LD_LIBRARY_PATH : ${lib.escapeShellArg LD_LIBRARY_PATH} 69 '' + lib.optionalString cudaSupport '' 70 for program in $out/bin/hashcat $out/bin/.hashcat-wrapped; do 71 isELF "$program" || continue 72 addOpenGLRunpath "$program" 73 done 74 ''; 75 76 meta = with lib; { 77 description = "Fast password cracker"; 78 homepage = "https://hashcat.net/hashcat/"; 79 license = licenses.mit; 80 platforms = platforms.unix; 81 maintainers = with maintainers; [ felixalbrigtsen kierdavis zimbatm ]; 82 }; 83}