Skip to content

Commit 3e04af3

Browse files
authored
Merge pull request #1770 from gpotter2/doc-u1
Small doc update
2 parents 4d5ddaf + 5e8e957 commit 3e04af3

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

doc/scapy/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# General information about the project.
4848
project = 'Scapy'
49-
copyright = '2008, 2018 Philippe Biondi and the Scapy community'
49+
copyright = '2008, 2019 Philippe Biondi and the Scapy community'
5050

5151
# The version info for the project you're documenting, acts as replacement for
5252
# |version| and |release|, also used in various other places throughout the

doc/scapy/installation.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Debian/Ubuntu
198198

199199
Just use the standard packages::
200200

201-
$ sudo apt-get install tcpdump graphviz imagemagick python-gnuplot python-cryptography python-pyx
201+
$ sudo apt-get install tcpdump graphviz imagemagick python-matplotlib python-cryptography python-pyx
202202

203203
Scapy optionally uses python-cryptography v1.7 or later. It has not been packaged for ``apt`` in less recent OS versions (e.g. Debian Jessie). If you need the cryptography-related methods, you may install the library with:
204204

@@ -223,12 +223,7 @@ Some optional packages:
223223

224224
.. code-block:: text
225225
226-
# yum install graphviz python-cryptography sox PyX gnuplot numpy
227-
# cd /tmp
228-
# wget http://heanet.dl.sourceforge.net/sourceforge/gnuplot-py/gnuplot-py-1.8.tar.gz
229-
# tar xvfz gnuplot-py-1.8.tar.gz
230-
# cd gnuplot-py-1.8
231-
# python setup.py install
226+
# yum install graphviz python-cryptography sox PyX matplotlib numpy
232227
233228
234229
Mac OS X
@@ -285,17 +280,19 @@ Here's how to install Scapy on OpenBSD 5.9+
285280
Optional packages (OpenBSD only)
286281
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
287282

283+
It is recommended to install those packages through `pip` rather than the OS, as the versions tend to be more up-to-date.
284+
288285
py-cryptography
289286

290287
.. code-block:: text
291288
292289
# pkg_add py-cryptography
293290
294-
gnuplot and its Python binding:
291+
matplotlib:
295292

296293
.. code-block:: text
297294
298-
# pkg_add gnuplot py-gnuplot
295+
# pkg_add matplotlib
299296
300297
Graphviz (large download, will install several GNOME libraries)
301298

doc/scapy/usage.rst

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ administrator privileges::
2222
If you do not have all optional packages installed, Scapy will inform you that
2323
some features will not be available::
2424

25-
INFO: Can't import python gnuplot wrapper . Won't be able to plot.
25+
INFO: Can't import python matplotlib wrapper. Won't be able to plot.
2626
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
2727

2828
The basic features of sending and receiving packets should still work, though.
2929

3030
Screenshot
3131
----------
3232

33-
If you have installed IPython, scapy will hook to it and you will be able to use auto-completion using the TAB.
33+
If you have installed IPython, Scapy will hook to it and you will be able to use auto-completion using the TAB.
3434

3535
.. image:: graphics/scapy-main-console.png
3636
:align: center
@@ -326,7 +326,7 @@ A DNS query (``rd`` = recursion desired). The host 192.168.5.1 is my DNS server.
326326
an=<DNSRR rrname='www.slashdot.org.' type=A rclass=IN ttl=3560L rdata='66.35.250.151' |>
327327
ns=0 ar=0 |<Padding load='\xc6\x94\xc7\xeb' |>>>>
328328

329-
The "send'n'receive" functions family is the heart of scapy. They return a couple of two lists. The first element is a list of couples (packet sent, answer), and the second element is the list of unanswered packets. These two elements are lists, but they are wrapped by an object to present them better, and to provide them with some methods that do most frequently needed actions::
329+
The "send'n'receive" functions family is the heart of Scapy. They return a couple of two lists. The first element is a list of couples (packet sent, answer), and the second element is the list of unanswered packets. These two elements are lists, but they are wrapped by an object to present them better, and to provide them with some methods that do most frequently needed actions::
330330

331331
>>> sr(IP(dst="192.168.8.1")/TCP(dport=[21,22,23]))
332332
Received 6 packets, got 3 answers, remaining 0 packets
@@ -337,7 +337,7 @@ The "send'n'receive" functions family is the heart of scapy. They return a coupl
337337
IP / TCP 192.168.8.14:20 > 192.168.8.1:22 S ==> Ether / IP / TCP 192.168.8.1:22 > 192.168.8.14:20 RA / Padding
338338
IP / TCP 192.168.8.14:20 > 192.168.8.1:23 S ==> Ether / IP / TCP 192.168.8.1:23 > 192.168.8.14:20 RA / Padding
339339
340-
If there is a limited rate of answers, you can specify a time interval to wait between two packets with the inter parameter. If some packets are lost or if specifying an interval is not enough, you can resend all the unanswered packets, either by calling the function again, directly with the unanswered list, or by specifying a retry parameter. If retry is 3, scapy will try to resend unanswered packets 3 times. If retry is -3, scapy will resend unanswered packets until no more answer is given for the same set of unanswered packets 3 times in a row. The timeout parameter specify the time to wait after the last packet has been sent::
340+
If there is a limited rate of answers, you can specify a time interval to wait between two packets with the inter parameter. If some packets are lost or if specifying an interval is not enough, you can resend all the unanswered packets, either by calling the function again, directly with the unanswered list, or by specifying a retry parameter. If retry is 3, Scapy will try to resend unanswered packets 3 times. If retry is -3, Scapy will resend unanswered packets until no more answer is given for the same set of unanswered packets 3 times in a row. The timeout parameter specify the time to wait after the last packet has been sent::
341341

342342
>>> sr(IP(dst="172.20.29.5/30")/TCP(dport=[21,22,23]),inter=0.5,retry=-2,timeout=1)
343343
Begin emission:
@@ -534,10 +534,22 @@ Configuring super sockets
534534
.. index::
535535
single: super socket
536536

537-
The process of sending packets and receiving is quite complicated. As I wanted to use the PF_PACKET interface to go through netfilter, I also needed to implement an ARP stack and ARP cache, and a LL stack. Well it seems to work, on ethernet and PPP interfaces, but I don't guarantee anything. Anyway, the fact I used a kind of super-socket for that mean that you can switch your IO layer very easily, and use PF_INET/SOCK_RAW, or use PF_PACKET at level 2 (giving the LL header (ethernet,...) and giving yourself mac addresses, ...). I've just added a super socket which use libdnet and libpcap, so that it should be portable::
537+
Different super sockets are available in Scapy: the native ones, and the ones that use a libpcap provider (that go through libpcap to send/receive packets).
538+
By default, Scapy will try to use the native ones (except on Windows, where the winpcap/npcap ones are preferred). To manually use the libpcap ones, you must:
538539

539-
>>> conf.L3socket=L3dnetSocket
540-
>>> conf.L3listen=L3pcapListenSocket
540+
* On Unix/OSX: be sure to have libpcap installed, and one of the following as libpcap python wrapper: `pcapy` or `pypcap`
541+
* On Windows: have Npcap/Winpcap installed. (default)
542+
543+
Then use:
544+
545+
>>> conf.use_pcap = True
546+
547+
This will automatically update the sockets pointing to `conf.L2socket` and `conf.L3socket`.
548+
549+
If you want to manually set them, you have a bunch of sockets available, depending on your platform. For instance, you might want to use:
550+
551+
>>> conf.L3socket=L3pcapSocket # Receive/send L3 packets through libpcap
552+
>>> conf.L2listen=L2ListenTcpdump # Receive L2 packets through TCPDump
541553

542554
Sniffing
543555
--------
@@ -878,7 +890,7 @@ Making tables
878890

879891
Now we have a demonstration of the ``make_table()`` presentation function. It takes a list as parameter, and a function who returns a 3-uple. The first element is the value on the x axis from an element of the list, the second is about the y value and the third is the value that we want to see at coordinates (x,y). The result is a table. This function has 2 variants, ``make_lined_table()`` and ``make_tex_table()`` to copy/paste into your LaTeX pentest report. Those functions are available as methods of a result object :
880892

881-
Here we can see a multi-parallel traceroute (scapy already has a multi TCP traceroute function. See later)::
893+
Here we can see a multi-parallel traceroute (Scapy already has a multi TCP traceroute function. See later)::
882894

883895
>>> ans, unans = sr(IP(dst="www.test.fr/30", ttl=(1,6))/TCP())
884896
Received 49 packets, got 24 answers, remaining 0 packets
@@ -914,7 +926,7 @@ Routing
914926
.. index::
915927
single: Routing, conf.route
916928

917-
Now scapy has its own routing table, so that you can have your packets routed differently than the system::
929+
Now Scapy has its own routing table, so that you can have your packets routed differently than the system::
918930

919931
>>> conf.route
920932
Network Netmask Gateway Iface
@@ -937,18 +949,18 @@ Now scapy has its own routing table, so that you can have your packets routed di
937949
192.168.8.0 255.255.255.0 0.0.0.0 eth0
938950
0.0.0.0 0.0.0.0 192.168.8.1 eth0
939951

940-
Gnuplot
941-
-------
952+
Matplotlib
953+
----------
942954

943955
.. index::
944-
single: Gnuplot, plot()
956+
single: Matplotlib, plot()
945957

946-
We can easily plot some harvested values using Gnuplot. (Make sure that you have Gnuplot-py and Gnuplot installed.)
958+
We can easily plot some harvested values using Matplotlib. (Make sure that you have matplotlib installed.)
947959
For example, we can observe the IP ID patterns to know how many distinct IP stacks are used behind a load balancer::
948960

949961
>>> a, b = sr(IP(dst="www.target.com")/TCP(sport=[RandShort()]*1000))
950962
>>> a.plot(lambda x:x[1].id)
951-
<Gnuplot._Gnuplot.Gnuplot instance at 0xb7d6a74c>
963+
[<matplotlib.lines.Line2D at 0x2367b80d6a0>]
952964

953965
.. image:: graphics/ipid.png
954966

@@ -959,7 +971,7 @@ TCP traceroute (2)
959971
.. index::
960972
single: traceroute(), Traceroute
961973

962-
Scapy also has a powerful TCP traceroute function. Unlike other traceroute programs that wait for each node to reply before going to the next, scapy sends all the packets at the same time. This has the disadvantage that it can't know when to stop (thus the maxttl parameter) but the great advantage that it took less than 3 seconds to get this multi-target traceroute result::
974+
Scapy also has a powerful TCP traceroute function. Unlike other traceroute programs that wait for each node to reply before going to the next, Scapy sends all the packets at the same time. This has the disadvantage that it can't know when to stop (thus the maxttl parameter) but the great advantage that it took less than 3 seconds to get this multi-target traceroute result::
963975

964976
>>> traceroute(["www.yahoo.com","www.altavista.com","www.wisenut.com","www.copernic.com"],maxttl=20)
965977
Received 80 packets, got 80 answers, remaining 0 packets
@@ -1084,8 +1096,8 @@ Provided that your wireless card and driver are correctly configured for frame i
10841096

10851097
On Windows, if using Npcap, the equivalent would be to call
10861098

1087-
# Of course, conf.iface can be replaced by any interfaces accessed through IFACES
1088-
>>> conf.iface.setmonitor(True)
1099+
>>> # Of course, conf.iface can be replaced by any interfaces accessed through IFACES
1100+
... conf.iface.setmonitor(True)
10891101

10901102
you can have a kind of FakeAP::
10911103

@@ -1095,7 +1107,7 @@ you can have a kind of FakeAP::
10951107
addr3="00:01:02:03:04:05")/
10961108
Dot11Beacon(cap="ESS", timestamp=1)/
10971109
Dot11Elt(ID="SSID", info=RandString(RandNum(1,50)))/
1098-
Dot11Elt(ID="Rates", info='\x82\x84\x0b\x16')/
1110+
Dot11EltRates(rates=[130, 132, 11, 22])/
10991111
Dot11Elt(ID="DSset", info="\x03")/
11001112
Dot11Elt(ID="TIM", info="\x00\x01\x00\x00"),
11011113
iface="mon0", loop=1)
@@ -1359,7 +1371,9 @@ Wireless sniffing
13591371

13601372
The following command will display information similar to most wireless sniffers::
13611373

1362-
>>> sniff(iface="ath0",prn=lambda x:x.sprintf("{Dot11Beacon:%Dot11.addr3%\t%Dot11Beacon.info%\t%PrismHeader.channel%\t%Dot11Beacon.cap%}"))
1374+
>>> sniff(iface="ath0", monitor=True, prn=lambda x:x.sprintf("{Dot11Beacon:%Dot11.addr3%\t%Dot11Beacon.info%\t%PrismHeader.channel%\t%Dot11Beacon.cap%}"))
1375+
1376+
Note the `monitor=True` argument, which only work from scapy>2.4.0 (2.4.0dev+), that is cross-platform. It will in work in most cases (Windows, OSX), but might require you to manually toggle monitor mode.
13631377

13641378
The above command will produce output similar to the one below::
13651379

0 commit comments

Comments
 (0)