about summary refs log tree commit diff
path: root/pkgs/tools/networking/aircrack-ng/default.nix
blob: 6bfd3136dc984dac2574b4a902a3b33a9cda6a3c (plain) (blame)
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
{ 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.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.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.isLinux [ libpcap zlib libnl iw ethtool pciutils ]
    ++ lib.optional (stdenv.isCygwin && stdenv.isClang) libiconv
    ++ lib.optional enableAirolib sqlite
    ++ lib.optional enableRegex pcre2
    ++ lib.optional useAirpcap airpcap-sdk;

  nativeCheckInputs = [ cmocka expect ];

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

  installCheckTarget = "integration";
  nativeInstallCheckInputs = [ cmocka expect ] ++ lib.optionals stdenv.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";
  };
}