2022-08-12 21:54:55 +00:00
|
|
|
{ buildPythonPackage, fetchFromGitHub, stdenv, lib, isPyPy
|
2018-08-07 16:52:47 +00:00
|
|
|
, pycrypto, ecdsa # TODO
|
2022-11-15 23:21:12 +00:00
|
|
|
, mock, can, brotli
|
2018-08-07 16:52:47 +00:00
|
|
|
, withOptionalDeps ? true, tcpdump, ipython
|
|
|
|
, withCryptography ? true, cryptography
|
|
|
|
, withVoipSupport ? true, sox
|
|
|
|
, withPlottingSupport ? true, matplotlib
|
|
|
|
, withGraphicsSupport ? false, pyx, texlive, graphviz, imagemagick
|
2018-08-07 17:10:56 +00:00
|
|
|
, withManufDb ? false, wireshark
|
2022-08-12 21:54:55 +00:00
|
|
|
, libpcap
|
2018-08-07 16:52:47 +00:00
|
|
|
# 2D/3D graphics and graphs TODO: VPython
|
|
|
|
# TODO: nmap, numpy
|
2018-02-15 21:40:01 +00:00
|
|
|
}:
|
2017-10-29 14:47:17 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2017-11-09 11:26:09 +00:00
|
|
|
pname = "scapy";
|
2021-04-20 12:06:19 +00:00
|
|
|
version = "2.4.5";
|
2017-10-29 14:47:17 +00:00
|
|
|
|
2018-03-27 16:26:03 +00:00
|
|
|
disabled = isPyPy;
|
2017-10-29 14:47:17 +00:00
|
|
|
|
2018-02-15 21:40:01 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "secdev";
|
|
|
|
repo = "scapy";
|
|
|
|
rev = "v${version}";
|
2021-04-20 12:06:19 +00:00
|
|
|
sha256 = "0nxci1v32h5517gl9ic6zjq8gc8drwr0n5pz04c91yl97xznnw94";
|
2017-10-29 14:47:17 +00:00
|
|
|
};
|
|
|
|
|
2022-08-12 21:54:55 +00:00
|
|
|
patches = [
|
|
|
|
./find-library.patch
|
|
|
|
];
|
|
|
|
|
2019-01-10 13:47:02 +00:00
|
|
|
postPatch = ''
|
2020-09-06 18:29:31 +00:00
|
|
|
printf "${version}" > scapy/VERSION
|
2022-08-12 21:54:55 +00:00
|
|
|
|
|
|
|
libpcap_file="${lib.getLib libpcap}/lib/libpcap${stdenv.hostPlatform.extensions.sharedLibrary}"
|
|
|
|
if ! [ -e "$libpcap_file" ]; then
|
|
|
|
echo "error: $libpcap_file not found" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
substituteInPlace "scapy/libs/winpcapy.py" \
|
|
|
|
--replace "@libpcap_file@" "$libpcap_file"
|
2019-01-10 13:47:02 +00:00
|
|
|
'' + lib.optionalString withManufDb ''
|
2018-08-07 17:10:56 +00:00
|
|
|
substituteInPlace scapy/data.py --replace "/opt/wireshark" "${wireshark}"
|
|
|
|
'';
|
|
|
|
|
2018-08-07 16:52:47 +00:00
|
|
|
propagatedBuildInputs = [ pycrypto ecdsa ]
|
2019-11-10 01:13:39 +00:00
|
|
|
++ lib.optionals withOptionalDeps [ tcpdump ipython ]
|
|
|
|
++ lib.optional withCryptography cryptography
|
|
|
|
++ lib.optional withVoipSupport sox
|
|
|
|
++ lib.optional withPlottingSupport matplotlib
|
2020-09-06 18:29:31 +00:00
|
|
|
++ lib.optionals withGraphicsSupport [ pyx texlive.combined.scheme-minimal graphviz imagemagick ];
|
2018-03-27 16:26:03 +00:00
|
|
|
|
2020-09-06 18:29:31 +00:00
|
|
|
# Running the tests seems too complicated:
|
|
|
|
doCheck = false;
|
2022-11-15 23:21:12 +00:00
|
|
|
checkInputs = [ mock can brotli ];
|
2020-09-06 18:29:31 +00:00
|
|
|
checkPhase = ''
|
2022-11-15 23:21:12 +00:00
|
|
|
# TODO: be more specific about files
|
2020-09-06 18:29:31 +00:00
|
|
|
patchShebangs .
|
|
|
|
.config/ci/test.sh
|
|
|
|
'';
|
2021-04-20 12:06:19 +00:00
|
|
|
pythonImportsCheck = [ "scapy" ];
|
2018-02-15 21:40:01 +00:00
|
|
|
|
2018-08-07 16:52:47 +00:00
|
|
|
meta = with lib; {
|
2020-09-06 18:29:31 +00:00
|
|
|
description = "A Python-based network packet manipulation program and library";
|
|
|
|
longDescription = ''
|
|
|
|
Scapy is a powerful Python-based interactive packet manipulation program
|
|
|
|
and library.
|
|
|
|
|
|
|
|
It is able to forge or decode packets of a wide number of protocols, send
|
|
|
|
them on the wire, capture them, store or read them using pcap files,
|
|
|
|
match requests and replies, and much more. It is designed to allow fast
|
|
|
|
packet prototyping by using default values that work.
|
|
|
|
|
|
|
|
It can easily handle most classical tasks like scanning, tracerouting,
|
|
|
|
probing, unit tests, attacks or network discovery (it can replace hping,
|
|
|
|
85% of nmap, arpspoof, arp-sk, arping, tcpdump, wireshark, p0f, etc.). It
|
|
|
|
also performs very well at a lot of other specific tasks that most other
|
|
|
|
tools can't handle, like sending invalid frames, injecting your own
|
|
|
|
802.11 frames, combining techniques (VLAN hopping+ARP cache poisoning,
|
|
|
|
VoIP decoding on WEP protected channel, ...), etc.
|
|
|
|
|
|
|
|
Scapy supports Python 2.7 and Python 3 (3.4 to 3.8). It's intended to be
|
|
|
|
cross platform, and runs on many different platforms (Linux, OSX, *BSD,
|
|
|
|
and Windows).
|
|
|
|
'';
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://scapy.net/";
|
2020-09-06 18:29:31 +00:00
|
|
|
changelog = "https://github.com/secdev/scapy/releases/tag/v${version}";
|
2021-04-20 12:06:19 +00:00
|
|
|
license = licenses.gpl2Only;
|
2019-02-17 13:00:33 +00:00
|
|
|
platforms = platforms.unix;
|
2018-02-15 21:40:01 +00:00
|
|
|
maintainers = with maintainers; [ primeos bjornfor ];
|
2017-10-29 14:47:17 +00:00
|
|
|
};
|
|
|
|
}
|