Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub, openssl, nss, nspr, libkrb5, gmp, zlib, libpcap, re2 2, gcc, python3Packages, perl, perlPackages, makeWrapper, fetchpatch 3}: 4 5stdenv.mkDerivation rec { 6 pname = "john"; 7 version = "1.9.0-jumbo-1"; 8 9 src = fetchFromGitHub { 10 owner = "openwall"; 11 repo = pname; 12 rev = "1.9.0-Jumbo-1"; 13 sha256 = "sha256-O1iPh5QTMjZ78sKvGbvSpaHFbBuVc1z49UKTbMa24Rs="; 14 }; 15 16 patches = [ 17 (fetchpatch { 18 name = "fix-gcc-11-struct-allignment-incompatibility.patch"; 19 url = "https://github.com/openwall/john/commit/154ee1156d62dd207aff0052b04c61796a1fde3b.patch"; 20 sha256 = "sha256-3rfS2tu/TF+KW2MQiR+bh4w/FVECciTooDQNTHNw31A="; 21 }) 22 (fetchpatch { 23 name = "improve-apple-clang-pseudo-intrinsics-portability.patch"; 24 url = "https://github.com/openwall/john/commit/c9825e688d1fb9fdd8942ceb0a6b4457b0f9f9b4.patch"; 25 excludes = [ "doc/*" ]; 26 sha256 = "sha256-hgoiz7IgR4f66fMP7bV1F8knJttY8g2Hxyk3QfkTu+g="; 27 }) 28 ]; 29 30 postPatch = '' 31 sed -ri -e ' 32 s!^(#define\s+CFG_[A-Z]+_NAME\s+).*/!\1"'"$out"'/etc/john/! 33 /^#define\s+JOHN_SYSTEMWIDE/s!/usr!'"$out"'! 34 ' src/params.h 35 sed -ri -e '/^\.include/ { 36 s!\$JOHN!'"$out"'/etc/john! 37 s!^(\.include\s*)<([^./]+\.conf)>!\1"'"$out"'/etc/john/\2"! 38 }' run/*.conf 39 ''; 40 41 preConfigure = '' 42 cd src 43 # Makefile.in depends on AS and LD being set to CC, which is set by default in configure.ac. 44 # This ensures we override the environment variables set in cc-wrapper/setup-hook.sh 45 export AS=$CC 46 export LD=$CC 47 ''; 48 configureFlags = [ 49 "--disable-native-tests" 50 "--with-systemwide" 51 ]; 52 53 buildInputs = [ openssl nss nspr libkrb5 gmp zlib libpcap re2 ]; 54 nativeBuildInputs = [ gcc python3Packages.wrapPython perl makeWrapper ]; 55 propagatedBuildInputs = (with python3Packages; [ dpkt scapy lxml ]) ++ # For pcap2john.py 56 (with perlPackages; [ DigestMD4 DigestSHA1 GetoptLong # For pass_gen.pl 57 CompressRawLzma # For 7z2john.pl 58 perlldap ]); # For sha-dump.pl 59 # TODO: Get dependencies for radius2john.pl and lion2john-alt.pl 60 61 # gcc -DAC_BUILT -Wall vncpcap2john.o memdbg.o -g -lpcap -fopenmp -o ../run/vncpcap2john 62 # gcc: error: memdbg.o: No such file or directory 63 enableParallelBuilding = false; 64 65 postInstall = '' 66 mkdir -p "$out/bin" "$out/etc/john" "$out/share/john" "$out/share/doc/john" "$out/share/john/rules" "$out/${perlPackages.perl.libPrefix}" 67 find -L ../run -mindepth 1 -maxdepth 1 -type f -executable \ 68 -exec cp -d {} "$out/bin" \; 69 cp -vt "$out/etc/john" ../run/*.conf 70 cp -vt "$out/share/john" ../run/*.chr ../run/password.lst 71 cp -vt "$out/share/john/rules" ../run/rules/*.rule 72 cp -vrt "$out/share/doc/john" ../doc/* 73 cp -vt "$out/${perlPackages.perl.libPrefix}" ../run/lib/* 74 ''; 75 76 postFixup = '' 77 wrapPythonPrograms 78 79 for i in $out/bin/*.pl; do 80 wrapProgram "$i" --prefix PERL5LIB : "$PERL5LIB:$out/${perlPackages.perl.libPrefix}" 81 done 82 ''; 83 84 meta = with lib; { 85 description = "John the Ripper password cracker"; 86 license = licenses.gpl2Plus; 87 homepage = "https://github.com/openwall/john/"; 88 maintainers = with maintainers; [ offline matthewbauer ]; 89 platforms = platforms.unix; 90 }; 91}