Download and Installation
Overview
InstallPython 3.7+.
(Optional):Install additional software for special features.
Run Scapy with root privileges.
Each of these steps can be done in a different way depending on your platform and on the version of Scapy you want to use. Follow the platform-specific instructions for more detail.
Scapy versions
Note
Scapy 2.5.0 was the last version to support Python 2.7 !
Scapy version | 2.3.3 | 2.5.0 | >2.5.0 |
---|---|---|---|
Python 2.2-2.6 | ✅ | ❌ | ❌ |
Python 2.7 | ✅ | ✅ | ❌ |
Python 3.4-3.6 | ❌ | ✅ | ❌ |
Python 3.7-3.11 | ❌ | ✅ | ✅ |
Installing Scapy v2.x
The following steps describe how to install (or update) Scapy itself.Dependent on your platform, some additional libraries might have to be installed to make it actually work.So please also have a look at the platform specific chapters on how to install those requirements.
Note
The following steps apply to Unix-like operating systems (Linux, BSD, Mac OS X).For Windows, see thespecial chapter below.
Make sure you have Python installed before you go on.
Latest release
Note
To get the latest versions, with bugfixes and new features, but maybe not as stable, see thedevelopment version.
Use pip:
$pipinstallscapy
Current development version
If you always want the latest version of Scapy with all new the features and bugfixes (but slightly less stable), you can install Scapy from its Git repository.
Note
If you don’t want to clone Scapy, you can install the development version in one line using:
$pipinstallhttps://github.com/secdev/scapy/archive/refs/heads/master.zip
Check out a clone of Scapy’s repository withgit:
$gitclonehttps://github.com/secdev/scapy.git$cdscapy
Install Scapy usingpip:
$pipinstall.
If you used Git, you can always update to the latest version afterwards:
$gitpull$pipinstall.
Note
You can run scapy without installing it using therun_scapy
(unix) orrun_scapy.bat
(Windows) script.
Optional Dependencies
For some special features, Scapy will need some dependencies to be installed.Most of those software are installable viapip
.Here are the topics involved and some examples that you can use to try if your installation was successful.
Plotting.
plot()
needsMatplotlib.Matplotlib is installable via
pipinstallmatplotlib
>>>p=sniff(count=50)>>>p.plot(lambdax:len(x))
2D graphics.
psdump()
andpdfdump()
needPyX which in turn needs a LaTeX distribution:texlive (Unix) orMikTex (Windows).You can install pyx using
pipinstallpyx
>>>p=IP()/ICMP()>>>p.pdfdump("test.pdf")
Graphs.
conversations()
needsGraphviz andImageMagick.>>>p=rdpcap("myfile.pcap")>>>p.conversations(type="jpg",target="> test.jpg")
Note
Graphviz
andImageMagick
need to be installed separately, using your platform-specific package manager.3D graphics.
trace3D()
needsVPython-Jupyter.VPython-Jupyter is installable via
pipinstallvpython
>>>a,u=traceroute(["www.python.org","google.com","slashdot.org"])>>>a.trace3D()
WEP decryption.
unwep()
needscryptography. Example using aWeplap test file:Cryptography is installable via
pipinstallcryptography
>>>enc=rdpcap("weplab-64bit-AA-managed.pcap")>>>enc.show()>>>enc[0]>>>conf.wepkey="AA\x00\x00\x00">>>dec=Dot11PacketList(enc).toEthernet()>>>dec.show()>>>dec[0]
PKI operations and TLS decryption.cryptography is also needed.
Fingerprinting.
nmap_fp()
needsNmap. You need anold version (before v4.23) that still supports first generation fingerprinting.>>>load_module("nmap")>>>nmap_fp("192.168.0.1")Begin emission:Finished to send 8 packets.Received 19 packets, got 4 answers, remaining 4 packets(0.88749999999999996, ['Draytek Vigor 2000 ISDN router'])
VOIP.
voip_play()
needsSoX.
Platform-specific instructions
As a general rule, you can toggle thelibpcap integrationon oroff at any time, using:
fromscapy.configimportconfconf.use_pcap=True
Linux native
Scapy can run natively on Linux, without libpcap.
InstallPython 3.7+.
Installlibpcap. (By default it will only be used to compile BPF filters)
Make sure your kernel has Packet sockets selected (
CONFIG_PACKET
)If your kernel is < 2.6, make sure that Socket filtering is selected
CONFIG_FILTER
)
Debian/Ubuntu/Fedora
Make sure libpcap is installed:
Debian/Ubuntu:
$ sudo apt-get install libpcap-dev
Fedora:
$ yum install libpcap-devel
Then install Scapy viapip
orapt
(bundled underpython3-scapy
)All dependencies may be installed either via the platform-specific installer, or via PyPI. SeeOptional Dependencies for more information.
Mac OS X
On Mac OS X, ScapyDOES work natively since the recent versions.However, you may want to make Scapy use libpcap.You can choose to install it using either Homebrew or MacPorts. They bothwork fine, yet Homebrew is used to run unit tests withTravis CI.
Note
Libpcap might already be installed on your platform (for instance, if you have tcpdump). This is the case ofOSX
Install using Homebrew
Update Homebrew:
$brewupdate
Install libpcap:
$brewinstalllibpcap
Enable it In Scapy:
conf.use_pcap=True
Install using MacPorts
Update MacPorts:
$sudoport-dselfupdate
Install libpcap:
$sudoportinstalllibpcap
Enable it In Scapy:
conf.use_pcap=True
OpenBSD
In a similar manner, to install Scapy on OpenBSD 5.9+, youmay want to install libpcap, if you do not want to use the native extension:
$ doas pkg_add libpcap
Then install Scapy viapip
orpkg_add
(bundled underpython-scapy
)All dependencies may be installed either via the platform-specific installer, or via PyPI. SeeOptional Dependencies for more information.
SunOS / Solaris
Solaris / SunOS requireslibpcap
(installed by default) to work.
Note
In fact, Solaris doesn’t supportAF_PACKET, which Scapy uses on Linux, but rather uses its own systemDLPI. Seethis page.We prefer using the very universallibpcap that spending time implementing support forDLPI.
Windows
You need to install Npcap in order to install Scapy on Windows (should also work with Winpcap, but unsupported nowadays):
Download link:Npcap:the latest version
- During installation:
we advise to turnoff the
Winpcapcompatibilitymode
if you want to use your wifi card in monitor mode (if supported), make sure you enable the
802.11
option
Once that is done, you cancontinue with Scapy’s installation.
You should then be able to open acmd.exe
and just callscapy
. If not, you probably haven’t enabled the “Add Python to PATH” option when installing Python. You can follow the instructionsover here to change that (or add it manually).
Screenshots


Build the documentation offline
The Scapy project’s documentation is written using reStructuredText (files *.rst) and can be built usingtheSphinx python library. The official online version is availableonreadthedocs.
HTML version
The instructions to build the HTML version are:
(activateavirtualenv)pipinstallsphinxcddoc/scapymakehtml
You can now open the resulting HTML file_build/html/index.html
in your favorite web browser.
To use the ReadTheDocs’ template, you will have to install the corresponding theme with:
pipinstallsphinx_rtd_theme
UML diagram
Usingpyreverse
you can build a UML representation of the Scapy source code’s object hierarchy. Here is anexample of how to build the inheritance graph for the Fields objects :
(activateavirtualenv)pipinstallpylintcdscapy/pyreverse-opng-pfieldsscapy/fields.py
This will generate aclasses_fields.png
picture containing the inheritance hierarchy. Note that you can provide as manymodules or packages as you want, but the result will quickly get unreadable.
To see the dependencies between the DHCP layer and the ansmachine module, you can run:
pyreverse-opng-pdhcp_ansscapy/ansmachine.pyscapy/layers/dhcp.pyscapy/packet.py
In this case, Pyreverse will also generate apackages_dhcp_ans.png
showing the link between the different python modules provided.