Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 buildPythonPackage, 3 fetchFromGitHub, 4 stdenv, 5 lib, 6 isPyPy, 7 pycrypto, 8 ecdsa, # TODO 9 mock, 10 can, 11 brotli, 12 withOptionalDeps ? true, 13 tcpdump, 14 ipython, 15 withCryptography ? true, 16 cryptography, 17 withVoipSupport ? true, 18 sox, 19 withPlottingSupport ? true, 20 matplotlib, 21 withGraphicsSupport ? false, 22 pyx, 23 texliveBasic, 24 graphviz, 25 imagemagick, 26 withManufDb ? false, 27 wireshark, 28 libpcap, 29# 2D/3D graphics and graphs TODO: VPython 30# TODO: nmap, numpy 31}: 32 33buildPythonPackage rec { 34 pname = "scapy"; 35 version = "2.5.0"; 36 format = "setuptools"; 37 38 disabled = isPyPy; 39 40 src = fetchFromGitHub { 41 owner = "secdev"; 42 repo = "scapy"; 43 rev = "v${version}"; 44 hash = "sha256-xJlovcxUQOQHfOU0Jgin/ayd2T5fOyeN4Jg0DbLHoeU="; 45 }; 46 47 patches = [ ./find-library.patch ]; 48 49 postPatch = 50 '' 51 printf "${version}" > scapy/VERSION 52 53 libpcap_file="${lib.getLib libpcap}/lib/libpcap${stdenv.hostPlatform.extensions.sharedLibrary}" 54 if ! [ -e "$libpcap_file" ]; then 55 echo "error: $libpcap_file not found" >&2 56 exit 1 57 fi 58 substituteInPlace "scapy/libs/winpcapy.py" \ 59 --replace "@libpcap_file@" "$libpcap_file" 60 '' 61 + lib.optionalString withManufDb '' 62 substituteInPlace scapy/data.py --replace "/opt/wireshark" "${wireshark}" 63 ''; 64 65 buildInputs = lib.optional withVoipSupport sox; 66 67 propagatedBuildInputs = 68 [ 69 pycrypto 70 ecdsa 71 ] 72 ++ lib.optionals withOptionalDeps [ 73 tcpdump 74 ipython 75 ] 76 ++ lib.optional withCryptography cryptography 77 ++ lib.optional withPlottingSupport matplotlib 78 ++ lib.optionals withGraphicsSupport [ 79 pyx 80 texliveBasic 81 graphviz 82 imagemagick 83 ]; 84 85 # Running the tests seems too complicated: 86 doCheck = false; 87 nativeCheckInputs = [ 88 mock 89 can 90 brotli 91 ]; 92 checkPhase = '' 93 # TODO: be more specific about files 94 patchShebangs . 95 .config/ci/test.sh 96 ''; 97 pythonImportsCheck = [ "scapy" ]; 98 99 meta = with lib; { 100 description = "Python-based network packet manipulation program and library"; 101 mainProgram = "scapy"; 102 longDescription = '' 103 Scapy is a powerful Python-based interactive packet manipulation program 104 and library. 105 106 It is able to forge or decode packets of a wide number of protocols, send 107 them on the wire, capture them, store or read them using pcap files, 108 match requests and replies, and much more. It is designed to allow fast 109 packet prototyping by using default values that work. 110 111 It can easily handle most classical tasks like scanning, tracerouting, 112 probing, unit tests, attacks or network discovery (it can replace hping, 113 85% of nmap, arpspoof, arp-sk, arping, tcpdump, wireshark, p0f, etc.). It 114 also performs very well at a lot of other specific tasks that most other 115 tools can't handle, like sending invalid frames, injecting your own 116 802.11 frames, combining techniques (VLAN hopping+ARP cache poisoning, 117 VoIP decoding on WEP protected channel, ...), etc. 118 119 Scapy supports Python 2.7 and Python 3 (3.4 to 3.8). It's intended to be 120 cross platform, and runs on many different platforms (Linux, OSX, *BSD, 121 and Windows). 122 ''; 123 homepage = "https://scapy.net/"; 124 changelog = "https://github.com/secdev/scapy/releases/tag/v${version}"; 125 license = licenses.gpl2Only; 126 platforms = platforms.unix; 127 maintainers = with maintainers; [ 128 primeos 129 bjornfor 130 ]; 131 }; 132}