summaryrefslogtreecommitdiff
path: root/pkgs/by-name/ai/aircrack-ng/package.nix
blob: fdc2284305e8392b2c03dfcb9c5528e93a1e87d9 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchzip,
  makeWrapper,
  autoreconfHook,
  pkg-config,
  openssl,
  libgcrypt,
  cmocka,
  expect,
  sqlite,
  pcre2,

  # Linux
  libpcap,
  zlib,
  wirelesstools,
  iw,
  ethtool,
  pciutils,
  libnl,
  usbutils,
  tcpdump,
  hostapd,
  wpa_supplicant,
  screen,

  # Cygwin
  libiconv,

  # options
  enableExperimental ? true,
  useGcrypt ? false,
  enableAirolib ? true,
  enableRegex ? true,
  useAirpcap ? stdenv.hostPlatform.isCygwin,
}:
let
  airpcap-sdk = fetchzip {
    pname = "airpcap-sdk";
    version = "4.1.1";
    url = "https://support.riverbed.com/bin/support/download?sid=l3vk3eu649usgu3rj60uncjqqu";
    hash = "sha256-kJhnUvhnF9F/kIJx9NcbRUfIXUSX/SRaO/SWNvdkVT8=";
    stripRoot = false;
    extension = "zip";
  };
in
stdenv.mkDerivation rec {
  pname = "aircrack-ng";
  version = "1.7";

  src = fetchFromGitHub {
    owner = "aircrack-ng";
    repo = "aircrack-ng";
    rev = version;
    hash = "sha256-niQDwiqi5GtBW5HIn0endnqPb/MqllcjsjXw4pTyFKY=";
  };

  postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
    substituteInPlace lib/osdep/linux.c --replace-warn /usr/local/bin ${
      lib.escapeShellArg (
        lib.makeBinPath [
          wirelesstools
        ]
      )
    }
  '';

  configureFlags = [
    (lib.withFeature enableExperimental "experimental")
    (lib.withFeature useGcrypt "gcrypt")
    (lib.withFeatureAs useAirpcap "airpcap" airpcap-sdk)
  ];

  nativeBuildInputs = [
    pkg-config
    makeWrapper
    autoreconfHook
  ];
  buildInputs =
    lib.singleton (if useGcrypt then libgcrypt else openssl)
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      libpcap
      zlib
      libnl
      iw
      ethtool
      pciutils
    ]
    ++ lib.optional (stdenv.hostPlatform.isCygwin && stdenv.hostPlatform.isClang) libiconv
    ++ lib.optional enableAirolib sqlite
    ++ lib.optional enableRegex pcre2
    ++ lib.optional useAirpcap airpcap-sdk;

  nativeCheckInputs = [
    cmocka
    expect
  ];

  postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
    wrapProgram "$out/bin/airmon-ng" --prefix PATH : ${
      lib.escapeShellArg (
        lib.makeBinPath [
          ethtool
          iw
          pciutils
          usbutils
        ]
      )
    }
  '';

  installCheckTarget = "integration";
  nativeInstallCheckInputs =
    [
      cmocka
      expect
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      tcpdump
      hostapd
      wpa_supplicant
      screen
    ];

  meta = {
    description = "WiFi security auditing tools suite";
    homepage = "https://www.aircrack-ng.org/";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ caralice ];
    platforms =
      with lib.platforms;
      builtins.concatLists [
        linux
        darwin
        cygwin
        netbsd
        openbsd
        freebsd
        illumos
      ];
    changelog = "https://github.com/aircrack-ng/aircrack-ng/blob/${src.rev}/ChangeLog";
  };
}