blob: 8f4963ce85e8eab9004dd6e5d6b82b414c3e2189 [file] [log] [blame] [view]
Guillaume Valadon9c789b32017-09-11 16:39:26 +02001<p align="center">
2 <img src="doc/scapy_logo.png" width=200>
3</p>
Pierre LALET064203b2016-01-12 11:36:39 +01004
Guillaume Valadon9c789b32017-09-11 16:39:26 +02005# Scapy #
The Gitter Badger0dfb1342017-07-05 15:41:47 +00006
Pierre LALET98256692016-12-15 09:55:58 +01007[![Travis Build Status](https://travis-ci.org/secdev/scapy.svg?branch=master)](https://travis-ci.org/secdev/scapy)
Pierre LALETd733f6b2017-03-15 17:11:30 +01008[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/secdev/scapy?svg=true)](https://ci.appveyor.com/project/secdev/scapy)
Pierre LALET69250062017-01-08 13:25:53 +01009[![Codecov Status](https://codecov.io/gh/secdev/scapy/branch/master/graph/badge.svg)](https://codecov.io/gh/secdev/scapy)
johnthagendb0e7152018-01-10 19:20:29 -050010[![PyPI Version](https://img.shields.io/pypi/v/scapy.svg)](https://pypi.python.org/pypi/scapy/)
johnthagen9481a652017-07-31 08:33:50 -040011[![Python Versions](https://img.shields.io/pypi/pyversions/scapy.svg)](https://pypi.python.org/pypi/scapy/)
Guillaume Valadon9c789b32017-09-11 16:39:26 +020012[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](LICENSE)
Guillaume Valadone8153252017-08-02 10:43:13 +020013[![Join the chat at https://gitter.im/secdev/scapy](https://badges.gitter.im/secdev/scapy.svg)](https://gitter.im/secdev/scapy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Victor Engmarkeb40f182016-06-11 10:16:51 +010014
Pierre LALET064203b2016-01-12 11:36:39 +010015
Guillaume Valadon9c789b32017-09-11 16:39:26 +020016Scapy is a powerful Python-based interactive packet manipulation program and
17library.
Pierre LALET064203b2016-01-12 11:36:39 +010018
Guillaume Valadon9c789b32017-09-11 16:39:26 +020019It is able to forge or decode packets of a wide number of protocols, send them
gpotter2a70aed42017-11-24 20:43:33 +010020on the wire, capture them, store or read them using pcap files, match requests
21and replies, and much more. It is designed to allow fast packet prototyping by
22using default values that work.
Pierre LALET064203b2016-01-12 11:36:39 +010023
Guillaume Valadon9c789b32017-09-11 16:39:26 +020024It can easily handle most classical tasks like scanning, tracerouting, probing,
johnthagen75433ce2018-01-18 16:12:52 -050025unit tests, attacks or network discovery (it can replace `hping`, 85% of `nmap`,
Guillaume Valadon9c789b32017-09-11 16:39:26 +020026`arpspoof`, `arp-sk`, `arping`, `tcpdump`, `wireshark`, `p0f`, etc.). It also
27performs very well at a lot of other specific tasks that most other tools can't
28handle, like sending invalid frames, injecting your own 802.11 frames, combining
29techniques (VLAN hopping+ARP cache poisoning, VoIP decoding on WEP protected
30channel, ...), etc.
gpotter298ea57e2017-01-08 12:52:30 +010031
Pierre LALET0b555e52017-12-27 15:28:48 +010032Scapy supports Python 2.7 and Python 3 (3.3 to 3.6). It's intended to
33be cross platform, and runs on many different platforms (Linux, OSX,
34*BSD, and Windows).
gpotter298ea57e2017-01-08 12:52:30 +010035
Guillaume Valadon9c789b32017-09-11 16:39:26 +020036## Hands-on ##
gpotter298ea57e2017-01-08 12:52:30 +010037
Guillaume Valadon9c789b32017-09-11 16:39:26 +020038### Interactive shell ###
gpotter298ea57e2017-01-08 12:52:30 +010039
Guillaume Valadon9c789b32017-09-11 16:39:26 +020040Scapy can easily be used as an interactive shell to interact with the network.
41The following example shows how to send an ICMP Echo Request message to
42`github.com`, then display the reply source IP address:
gpotter298ea57e2017-01-08 12:52:30 +010043
Guillaume Valadon9c789b32017-09-11 16:39:26 +020044```python
45sudo ./run_scapy
46Welcome to Scapy
47>>> p = IP(dst="github.com")/ICMP()
48>>> r = sr1(p)
49Begin emission:
50.Finished to send 1 packets.
51*
52Received 2 packets, got 1 answers, remaining 0 packets
53>>> r[IP].src
54'192.30.253.113'
55```
Pierre LALET064203b2016-01-12 11:36:39 +010056
Guillaume Valadon9c789b32017-09-11 16:39:26 +020057### Python module ###
58
59It is straightforward to use Scapy as a regular Python module, for example to
60check if a TCP port is opened. First, save the following code in a file names
61`send_tcp_syn.py`
62
63```python
64from scapy.all import *
65conf.verb = 0
66
67p = IP(dst="github.com")/TCP()
68r = sr1(p)
johnthagen69cc3212018-01-17 22:01:19 -050069print(r.summary())
Guillaume Valadon9c789b32017-09-11 16:39:26 +020070```
71
72Then, launch the script with:
73```python
74sudo python send_tcp_syn.py
75IP / TCP 192.30.253.113:http > 192.168.46.10:ftp_data SA / Padding
76```
77
Guillaume Valadon7ccb9252018-01-10 07:55:05 +010078### Resources ###
Guillaume Valadon9c789b32017-09-11 16:39:26 +020079
80To begin with Scapy, you should check [the notebook
81hands-on](doc/notebooks/Scapy%20in%2015%20minutes.ipynb) and the [interactive
82tutorial](http://scapy.readthedocs.io/en/latest/usage.html#interactive-tutorial).
83If you want to learn more, see [the quick demo: an interactive
84session](http://scapy.readthedocs.io/en/latest/introduction.html#quick-demo)
85(some examples may be outdated), or play with the
86[HTTP/2](doc/notebooks/HTTP_2_Tuto.ipynb) and [TLS](doc/notebooks/tls)
87notebooks.
88
Guillaume Valadon7ccb9252018-01-10 07:55:05 +010089The [documentation](http://scapy.readthedocs.io/en/latest/) contains more
90advanced use cases, and examples.
Guillaume Valadon9c789b32017-09-11 16:39:26 +020091
92## Installation ##
93
94Scapy works without any external Python modules on Linux and BSD like operating
95systems. On Windows, you need to install some mandatory dependencies as
96described in [the
97documentation](http://scapy.readthedocs.io/en/latest/installation.html#windows).
98
99On most systems, using Scapy is as simple as running the following commands:
100```
101git clone https://github.com/secdev/scapy
102cd scapy
103./run_scapy
104>>>
105```
106
107To benefit from all Scapy features, such as plotting, you might want to install
108Python modules, such as `matplotlib` or `cryptography`. See the
109[documentation](http://scapy.readthedocs.io/en/latest/installation.html) and
110follow the instructions to install them.
111
Guillaume Valadon9c789b32017-09-11 16:39:26 +0200112## Contributing ##
Pierre LALETaf2a96b2016-02-09 13:38:04 +0100113
114Want to contribute? Great! Please take a few minutes to
115[read this](CONTRIBUTING.md)!