Skip to content

Commit 8b002b6

Browse files
authored
Include modules/ in doc and improve doc (#4748)
1 parent c419e66 commit 8b002b6

5 files changed

Lines changed: 47 additions & 45 deletions

File tree

doc/scapy/layers/kerberos.rst

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,21 @@ Kerberos
33

44
.. note:: Kerberos per `RFC4120 <https://datatracker.ietf.org/doc/html/rfc6113.html>`_ + `RFC6113 <https://datatracker.ietf.org/doc/html/rfc6113.html>`_ (FAST) + `[MS-KILE] <https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-kile/2a32282e-dd48-4ad9-a542-609804b02cc9>`_ (Windows)
55

6-
High-Level
7-
__________
8-
9-
Scapy provides several high-level utilities related to Kerberos:
10-
11-
- ``Ticketer``: a module that allows manipulating Kerberos tickets:
12-
- Request TGT/ST
13-
- Generate a ``KerberosSSP`` from a ST
14-
- Renew tickets
15-
- Read, create, write **ccache** files
16-
- Read, create, write **keytab** files
17-
- Kerberos armoring (via FAST) is available
18-
- S4U2Self / S4U2Proxy are implemented
19-
- KPasswd is implemented
20-
- ``KerberosSSP``: an implementation of a GSSAPI SSP for Kerberos, usable in any of Scapy's client that support GSSAPI.
21-
- Encryption/MIC using GSSAPI is available
22-
- Channel bindings are supported
23-
- U2U (User-To-User) is fully supported
24-
- [MS-KKDCP] (KDC proxy) is supported
6+
Scapy's Kerberos implementation is accessed through two main components:
7+
8+
- :class:`~scapy.modules.ticketer.Ticketer`: a module that allows manipulating Kerberos tickets;
9+
- :class:`~scapy.layers.kerberos.KerberosSSP`: an implementation of a GSSAPI SSP for Kerberos, usable in any of Scapy's client that support GSSAPI, for both authentication and encryption.
10+
11+
The general idea is that the first one allows to request tickets and perform almost all Kerberos related operations (S4U2Self, S4U2Proxy, FAST armoring, U2U, DMSA, etc.). The latter is used once a final Service Ticket is obtained, by other parts of Scapy, for instance `SMB <smb.html>`_, `LDAP <ldap.html>`_ or `DCE/RPC <dcerpc.html>`_.
2512

2613
Ticketer module
2714
~~~~~~~~~~~~~~~
2815

29-
The **Ticketer** module can be used both from the CLI or programmatically. This section tries to give many usage examples of features
30-
that are available. For more detail regarding the parameters of the functions, it is encouraged to have a look at their docstrings.
16+
The :class:`~scapy.modules.ticketer.Ticketer` module can be used both from the CLI or programmatically to perform operations on Kerberos tickets. To use it, you must first create an instance of a :class:`~scapy.modules.ticketer.Ticketer`, which acts as both a **ccache** (holds tickets) and a **keytab** (holds secrets).
17+
18+
This section tries to give many usage examples, but isn't exhaustive. For more details regarding the parameters of each functions, it is encouraged to have a look at the docstrings of :class:`~scapy.layers.kerberos.KerberosClient`.
3119

32-
- **Request TGT**:
20+
- **Request TGT**: see the docstring of :func:`~scapy.layers.kerberos.krb_as_req`
3321

3422
.. code:: pycon
3523
@@ -44,7 +32,7 @@ that are available. For more detail regarding the parameters of the functions, i
4432
31/08/23 11:38:34 31/08/23 21:38:34 31/08/23 21:38:35 31/08/23 01:38:34
4533
4634
47-
- **Then request a ST, using the TGT**:
35+
- **Then request a ST, using the TGT**: see the docstring of :func:`~scapy.layers.kerberos.krb_tgs_req`
4836

4937
.. code:: pycon
5038
@@ -61,7 +49,7 @@ that are available. For more detail regarding the parameters of the functions, i
6149
31/08/23 11:39:07 31/08/23 21:38:34 31/08/23 21:38:35 31/08/23 01:38:34
6250
6351
64-
- **Use ticket as SSP**: the ``.ssp()`` function.
52+
- **Use ticket as SSP**: the :func:`~scapy.modules.ticketer.Ticketer.ssp` function.
6553

6654
.. code:: pycon
6755
@@ -467,11 +455,12 @@ You can typically use it in :class:`~scapy.layers.smbclient.SMB_Client`, :class:
467455

468456
.. note:: Remember that you can wrap it in a :class:`~scapy.layers.spnego.SPNEGOSSP`
469457

470-
Low-level
471-
_________
458+
See `GSSAPI <gssapi.html>`_ for usage examples.
472459

473-
Decrypt kerberos packets
474-
~~~~~~~~~~~~~~~~~~~~~~~~
460+
Decrypt kerberos packets manually
461+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
462+
463+
.. note:: This section is useful to understand the inner workings of Kerberos, but isn't necessary to use Scapy's implementation.
475464

476465
Kerberos packets contain encrypted content, let's take the following packet:
477466

@@ -576,10 +565,10 @@ Let's run a few examples:
576565
'4c01cd46d632d01e6dbe230a01ed642a'
577566
578567
579-
Decrypt FAST
580-
~~~~~~~~~~~~
568+
Decrypt FAST manually
569+
~~~~~~~~~~~~~~~~~~~~~
581570

582-
.. note:: Have a look at `RFC6113 <https://datatracker.ietf.org/doc/html/rfc6113.html>`_ for Kerberos FAST
571+
.. note:: This section is useful to understand the inner workings of Kerberos FAST, but FAST can simply be used in :class:`~scapy.modules.ticketer.Ticketer` through the ``armor_with`` parameter when performing either a ASREQ or TGSREQ. For more details related to how FAST works, have a look at `RFC6113 <https://datatracker.ietf.org/doc/html/rfc6113.html>`_.
583572

584573
Let's take a Kerberos AS-REQ packet with FAST armoring (RFC6113):
585574

@@ -802,8 +791,8 @@ That we can now use to decrypt the last payload:
802791
| encAuthorizationData= None
803792
| additionalTickets= None
804793
805-
Encryption
806-
~~~~~~~~~~
794+
Manually using Kerberos encryption
795+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
807796

808797
A :func:`~scapy.libs.rfc3961.Key.encrypt` function exists in the :class:`~scapy.libs.rfc3961.Key` object in order to do the opposite of :func:`~scapy.libs.rfc3961.Key.decrypt`.
809798

scapy/libs/extcap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ def _format(self,
233233

234234
def load_extcap() -> None:
235235
"""
236-
Load extcap folder from wireshark and populate providers
236+
Load extcap folder from wireshark and populate Scapy's providers.
237+
238+
Additional interfaces should appear in conf.ifaces.
237239
"""
238240
if WINDOWS:
239241
pattern = re.compile(r"^[^.]+(?:\.bat|\.exe)?$")

scapy/libs/rfc3961.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
- RFC 4757: The RC4-HMAC Kerberos Encryption Types Used by Microsoft Windows
1414
- RFC 6113: A Generalized Framework for Kerberos Pre-Authentication
1515
- RFC 8009: AES Encryption with HMAC-SHA2 for Kerberos 5
16+
17+
.. note::
18+
You will find more complete documentation for Kerberos over at
19+
`SMB <https://scapy.readthedocs.io/en/latest/layers/kerberos.html>`_
1620
"""
1721

1822
# TODO: support cipher states...

scapy/modules/p0f.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,16 @@ def __init__(self, label_id, sig_line):
333333

334334
class p0fKnowledgeBase(KnowledgeBase):
335335
"""
336-
self.base = {
337-
"mtu" (str): [sig(tuple), ...]
338-
"tcp"/"http" (str): {
339-
direction (str): [sig(tuple), ...]
336+
.. code::
337+
338+
self.base = {
339+
"mtu" (str): [sig(tuple), ...]
340+
"tcp"/"http" (str): {
341+
direction (str): [sig(tuple), ...]
340342
}
341-
}
342-
self.labels = (label(tuple), ...)
343+
}
344+
self.labels = (label(tuple), ...)
345+
343346
"""
344347
def lazy_init(self):
345348
try:
@@ -753,10 +756,12 @@ def add_field(name, value):
753756

754757
def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
755758
extrahops=0, mtu=1500, uptime=None):
756-
"""Modifies pkt so that p0f will think it has been sent by a
759+
"""
760+
Modifies pkt so that p0f will think it has been sent by a
757761
specific OS. Either osgenre or signature is required to impersonate.
758762
If signature is specified (as a raw string), we use the signature.
759-
signature format:
763+
signature format::
764+
760765
"ip_ver:ttl:ip_opt_len:mss:window,wscale:opt_layout:quirks:pay_class"
761766
762767
If osgenre is specified, we randomly pick a signature with a label
@@ -765,7 +770,8 @@ def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
765770
is a substring of a label flavor ("7", "8" and "7 or 8" will
766771
all match the label "s:win:Windows:7 or 8")
767772
768-
For now, only TCP SYN/SYN+ACK packets are supported."""
773+
For now, only TCP SYN/SYN+ACK packets are supported.
774+
"""
769775
pkt = validate_packet(pkt)
770776

771777
if not osgenre and not signature:

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ description = "Regenerates the API reference doc tree"
9494
skip_install = true
9595
changedir = {toxinidir}/doc/scapy
9696
deps = sphinx
97+
cryptography
9798
commands =
98-
sphinx-apidoc -f --no-toc -d 1 --separate --module-first --templatedir=_templates --output-dir api ../../scapy ../../scapy/modules/ ../../scapy/libs/ ../../scapy/tools/ ../../scapy/arch/ ../../scapy/contrib/scada/* ../../scapy/layers/msrpce/raw/ ../../scapy/layers/msrpce/all.py ../../scapy/all.py ../../scapy/layers/all.py ../../scapy/compat.py
99+
sphinx-apidoc -f --no-toc -d 1 --separate --module-first --templatedir=_templates --output-dir api ../../scapy ../../scapy/modules/voip.py ../../scapy/modules/krack/ ../../scapy/libs/winpcapy.py ../../scapy/libs/ethertypes.py ../../scapy/libs/m*.py ../../scapy/libs/structures.py ../../scapy/libs/test_pyx.py ../../scapy/tools/ ../../scapy/arch/ ../../scapy/contrib/scada/* ../../scapy/layers/msrpce/raw/ ../../scapy/layers/msrpce/all.py ../../scapy/all.py ../../scapy/layers/all.py ../../scapy/compat.py
99100

100101

101102
[testenv:mypy]
@@ -109,7 +110,7 @@ commands = python .config/mypy/mypy_check.py linux
109110

110111
[testenv:docs]
111112
description = "Build the docs"
112-
deps =
113+
deps = cryptography
113114
extras = doc
114115
changedir = {toxinidir}/doc/scapy
115116
commands =

0 commit comments

Comments
 (0)