Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / ar / armitage / package.nix
blobef2b5c3101c7d11a3656ca13822429ba9b0d80ee
1 { lib
2 , stdenv
3 , fetchurl
4 , fetchFromGitHub
5 , jdk11
6 , gradle_6
7 , metasploit
8 , makeWrapper
9 , makeDesktopItem
10 , copyDesktopItems
11 , writeDarwinBundle
14 let
15   pname = "armitage";
16   version = "unstable-2022-12-05";
18   gradle = gradle_6;
20   src = fetchFromGitHub {
21     owner = "r00t0v3rr1d3";
22     repo = "armitage";
23     rev = "991244e9a0c0fc9302e48c4e708347c315f78b13";
24     hash = "sha256-0ik20wzE0cf6cC/HY6RwMHqkvqPFpZmOUyZyb5H3SHg=";
25   };
27   patches = [
28     (fetchurl {
29       name = "Remove-mentions-of-old-metasploit-versions.patch";
30       url = "https://gitlab.com/kalilinux/packages/armitage/-/raw/042beb7494a10227761ecb3ddabf4019bbb78681/debian/patches/Remove-mentions-of-old-metasploit-versions.patch";
31       hash = "sha256-VUey/e8kcBWqAxYTfIXoyTAoDR/UKZKqBJAKmdabArY=";
32     })
33     (fetchurl {
34       name = "Update-postgresql-version-to-support-scram-sha-256.patch";
35       url = "https://gitlab.com/kalilinux/packages/armitage/-/raw/042beb7494a10227761ecb3ddabf4019bbb78681/debian/patches/Update-postgresql-version-to-support-scram-sha-256.patch";
36       hash = "sha256-ZPvcRoUCrq32g0Mw8+EhNl8DlI+jMYUlFyPW1VScgzc=";
37     })
38     (fetchurl {
39       name = "fix-launch-script.patch";
40       url = "https://gitlab.com/kalilinux/packages/armitage/-/raw/042beb7494a10227761ecb3ddabf4019bbb78681/debian/patches/fix-launch-script.patch";
41       hash = "sha256-I6T7iwShQLn+ZHuKa117VOlItXjY4/51RDbjvNJEW/4=";
42     })
43     (fetchurl {
44       name = "fix-meterpreter.patch";
45       url = "https://gitlab.com/kalilinux/packages/armitage/-/raw/042beb7494a10227761ecb3ddabf4019bbb78681/debian/patches/fix-meterpreter.patch";
46       hash = "sha256-p4fs5xFdC2apW0U8x8u9S4p5gq3Eiv+0E4CGccQZYKY=";
47     })
48   ];
51 stdenv.mkDerivation (finalAttrs: {
52   inherit pname version src patches;
54   desktopItems = [
55     (makeDesktopItem {
56       name = "armitage";
57       desktopName = "Armitage";
58       exec = "armitage";
59       icon = "armitage";
60       comment = finalAttrs.meta.description;
61       categories = [ "Network" "Security" ];
62       startupNotify = false;
63     })
64   ];
66   nativeBuildInputs = [
67     jdk11
68     gradle
69     makeWrapper
70     copyDesktopItems
71   ] ++ lib.optionals stdenv.isDarwin [
72     writeDarwinBundle
73   ];
75   mitmCache = gradle.fetchDeps {
76     inherit pname;
77     data = ./deps.json;
78   };
80   __darwinAllowLocalNetworking = true;
82   installPhase = ''
83     runHook preInstall
85     JAR="$out/share/armitage/armitage.jar"
86     install -Dm444 build/armitage.jar $JAR
88     install -Dm755 dist/unix/armitage $out/bin/armitage
89     substituteInPlace $out/bin/armitage \
90       --replace "armitage.jar" "$JAR"
91     wrapProgram $out/bin/armitage \
92       --prefix PATH : "${lib.makeBinPath [ jdk11 metasploit ]}"
94     install -Dm755 dist/unix/teamserver $out/bin/teamserver
95     substituteInPlace $out/bin/teamserver \
96       --replace "armitage.jar" "$JAR"
97     wrapProgram $out/bin/teamserver \
98       --prefix PATH : "${lib.makeBinPath [ jdk11 metasploit ]}"
100     install -Dm444 dist/unix/armitage-logo.png $out/share/pixmaps/armitage.png
101     ${lib.optionalString stdenv.isDarwin ''
102       mkdir -p "$out/Applications/Armitage.app/Contents/MacOS"
103       mkdir -p "$out/Applications/Armitage.app/Contents/Resources"
104       cp dist/mac/Armitage.app/Contents/Resources/macIcon.icns $out/Applications/Armitage.app/Contents/Resources
105       write-darwin-bundle $out Armitage armitage macIcon
106     ''}
108     runHook postInstall
109   '';
111   meta = with lib; {
112     description = "Graphical cyber attack management tool for Metasploit";
113     homepage = "https://github.com/r00t0v3rr1d3/armitage";
114     license = licenses.bsd3;
115     maintainers = with maintainers; [ emilytrau ];
116     platforms = platforms.unix;
117     mainProgram = "armitage";
118   };