Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 openssl, 6 nss, 7 nspr, 8 libkrb5, 9 gmp, 10 zlib, 11 libpcap, 12 re2, 13 gcc, 14 python3Packages, 15 perl, 16 perlPackages, 17 withOpenCL ? true, 18 opencl-headers, 19 ocl-icd, 20 # include non-free ClamAV unrar code 21 enableUnfree ? false, 22 replaceVars, 23 makeWrapper, 24}: 25 26stdenv.mkDerivation { 27 pname = "john"; 28 version = "rolling-2404"; 29 30 src = fetchFromGitHub { 31 owner = "openwall"; 32 repo = "john"; 33 rev = "f9fedd238b0b1d69181c1fef033b85c787e96e57"; 34 hash = "sha256-zvoN+8Sx6qpVg2JeRLOIH1ehfl3tFTv7r5wQZ44Qsbc="; 35 }; 36 37 patches = lib.optionals withOpenCL [ 38 (replaceVars ./opencl.patch { 39 ocl_icd = ocl-icd; 40 }) 41 ]; 42 43 postPatch = '' 44 sed -ri -e ' 45 s!^(#define\s+CFG_[A-Z]+_NAME\s+).*/!\1"'"$out"'/etc/john/! 46 /^#define\s+JOHN_SYSTEMWIDE/s!/usr!'"$out"'! 47 ' src/params.h 48 sed -ri -e '/^\.include/ { 49 s!\$JOHN!'"$out"'/etc/john! 50 s!^(\.include\s*)<([^./]+\.conf)>!\1"'"$out"'/etc/john/\2"! 51 }' run/*.conf 52 ''; 53 54 preConfigure = '' 55 cd src 56 # Makefile.in depends on AS and LD being set to CC, which is set by default in configure.ac. 57 # This ensures we override the environment variables set in cc-wrapper/setup-hook.sh 58 export AS=$CC 59 export LD=$CC 60 '' 61 + lib.optionalString withOpenCL '' 62 python ./opencl_generate_dynamic_loader.py # Update opencl_dynamic_loader.c 63 ''; 64 configureFlags = [ 65 "--disable-native-tests" 66 "--with-systemwide" 67 ] 68 ++ lib.optionals (!enableUnfree) [ "--without-unrar" ]; 69 70 buildInputs = [ 71 openssl 72 nss 73 nspr 74 libkrb5 75 gmp 76 zlib 77 libpcap 78 re2 79 ] 80 ++ lib.optionals withOpenCL [ 81 opencl-headers 82 ocl-icd 83 ]; 84 nativeBuildInputs = [ 85 gcc 86 python3Packages.wrapPython 87 perl 88 makeWrapper 89 ]; 90 propagatedBuildInputs = 91 # For pcap2john.py 92 (with python3Packages; [ 93 dpkt 94 scapy 95 lxml 96 ]) 97 ++ (with perlPackages; [ 98 # For pass_gen.pl 99 DigestMD4 100 DigestSHA1 101 GetoptLong 102 # For 7z2john.pl 103 CompressRawLzma 104 # For sha-dump.pl 105 perlldap 106 ]); 107 # TODO: Get dependencies for radius2john.pl and lion2john-alt.pl 108 109 # gcc -DAC_BUILT -Wall vncpcap2john.o memdbg.o -g -lpcap -fopenmp -o ../run/vncpcap2john 110 # gcc: error: memdbg.o: No such file or directory 111 enableParallelBuilding = false; 112 113 postInstall = '' 114 mkdir -p "$out/bin" "$out/etc/john" "$out/share/john" "$out/share/doc/john" "$out/share/john/rules" "$out/share/john/opencl" "$out/${perlPackages.perl.libPrefix}" 115 find -L ../run -mindepth 1 -maxdepth 1 -type f -executable \ 116 -exec cp -d {} "$out/bin" \; 117 cp -vt "$out/etc/john" ../run/*.conf 118 cp -vt "$out/share/john" ../run/*.chr ../run/password.lst 119 cp -vt "$out/share/john/rules" ../run/rules/*.rule 120 cp -vt "$out/share/john/opencl" ../run/opencl/*.cl ../run/opencl/*.h 121 cp -vLrt "$out/share/doc/john" ../doc/* 122 cp -vt "$out/${perlPackages.perl.libPrefix}" ../run/lib/* 123 ''; 124 125 postFixup = '' 126 wrapPythonPrograms 127 128 for i in $out/bin/*.pl; do 129 wrapProgram "$i" --prefix PERL5LIB : "$PERL5LIB:$out/${perlPackages.perl.libPrefix}" 130 done 131 ''; 132 133 meta = with lib; { 134 description = "John the Ripper password cracker"; 135 license = [ licenses.gpl2Plus ] ++ lib.optionals enableUnfree [ licenses.unfreeRedistributable ]; 136 homepage = "https://github.com/openwall/john/"; 137 maintainers = with maintainers; [ 138 offline 139 matthewbauer 140 cherrykitten 141 ]; 142 platforms = platforms.unix; 143 }; 144}