You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- All SSPs: support PFC_SUPPORT_HEADER_SIGN for DCE/RPC
- Refactor SSPs and DCE/RPC client/server to use req_flags in GSS_Init_sec_context
- KerberosSSP:
- support DCE_STYLE (for DCE/RPC)
- add MIC/WRAP support
- NTLMSSP: fix SeqNum when used with SPNEGO
- Fix a bunch of SPNEGO edge cases
- Many tests
Copy file name to clipboardExpand all lines: doc/scapy/layers/dcerpc.rst
+102-6Lines changed: 102 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,20 +192,77 @@ Here's an example sending a ``ServerAlive`` over the ``IObjectExporter`` interfa
192
192
resp = client.sr1_req(req)
193
193
resp.show()
194
194
195
-
Here's a different example, this time connecting over ``NCACN_NP`` to `[MS-SAMR] <https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/4df07fab-1bbc-452f-8e92-7853a3c7e380>`_ to enumerate the domains a server is in:
195
+
Here's the same example, but this time asking for :const:`~scapy.layers.dcerpc.RPC_C_AUTHN_LEVEL.PKT_PRIVACY` (encryption) using ``NTLMSSP``:
Here's a different example, this time connecting over :const:`~scapy.layers.dcerpc.DCERPC_Transport.NCACN_NP` to `[MS-SAMR] <https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/4df07fab-1bbc-452f-8e92-7853a3c7e380>`_ to enumerate the domains a server is in:
196
252
197
253
.. code-block:: python
198
254
199
255
from scapy.layers.ntlm importNTLMSSP, MD4le
200
256
from scapy.layers.dcerpc import*
201
257
from scapy.layers.msrpce.all import*
202
258
259
+
ssp = NTLMSSP(
260
+
UPN="User",
261
+
HASHNT=MD4le("Password"),
262
+
)
203
263
client = DCERPC_Client(
204
264
DCERPC_Transport.NCACN_NP,
205
-
ssp=NTLMSSP(
206
-
UPN="User",
207
-
HASHNT=MD4le("Password"),
208
-
),
265
+
ssp=ssp,
209
266
ndr64=False,
210
267
)
211
268
client.connect("192.168.0.100")
@@ -238,7 +295,9 @@ Here's a different example, this time connecting over ``NCACN_NP`` to `[MS-SAMR]
238
295
239
296
.. note:: As you can see, we used the :class:`~scapy.layers.ntlm.NTLMSSP` security provider in the above connection.
240
297
241
-
There's an extension of the ``DCERPC_Client``: the ``NetlogonClient`` which is unfinished because I can't seem to make ``NetrLogonGetCapabilities`` work, but worth mentioning because it implements its own ``NetlogonSSP``:
298
+
There are extensions to the :class:`~scapy.layers.msrpce.rpcclient.DCERPC_Client` class:
299
+
300
+
- the :class:`~scapy.layers.msrpce.msnrpc.NetlogonClient`, worth mentioning because it implements its own :class:`~scapy.layers.msrpce.msnrpc.NetlogonSSP`:
242
301
243
302
.. code-block:: python
244
303
@@ -254,6 +313,8 @@ There's an extension of the ``DCERPC_Client``: the ``NetlogonClient`` which is u
- the :class:`~scapy.layers.msrpce.msdcom.DCOM_Client` (unfinished)
317
+
257
318
Server
258
319
------
259
320
@@ -335,6 +396,41 @@ To start an endpoint mapper (this should be a separate process from your RPC ser
335
396
.. note:: Currently, a DCERPC_Server will let a client bind on all interfaces that Scapy has registered (imported). Supposedly though, you know which RPCs are going to be queried.
336
397
337
398
399
+
Passive sniffing
400
+
----------------
401
+
402
+
If you're doing passive sniffing of a DCE/RPC session, you can instruct Scapy to still use its DCE/RPC session in order to check the INTEGRITY and decrypt (if PRIVACY is used) the packets.
403
+
404
+
.. code-block:: python
405
+
406
+
from scapy.all import*
407
+
408
+
# Bind DCE/RPC port
409
+
bind_bottom_up(TCP, DceRpc5, dport=12345)
410
+
bind_bottom_up(TCP, DceRpc5, dport=12345)
411
+
412
+
# Enable passive DCE/RPC session
413
+
conf.dcerpc_session_enable =True
414
+
415
+
# Define SSPs that can be used for decryption / verify
Scapy provides access to various `Security Providers <https://learn.microsoft.com/en-us/windows-server/security/windows-authentication/security-support-provider-interface-architecture>`_ following the GSSAPI model, but aiming at interacting with the Windows world.
5
+
6
+
.. note::
7
+
8
+
The GSSAPI interfaces are based off the following documentations:
Basically those are classes that implement two functions, trying to micmic the RFCs:
24
+
25
+
- :func:`~scapy.layers.gssapi.SSP.GSS_Init_sec_context`: called by the client, passing it a ``Context`` and optionally a token
26
+
- :func:`~scapy.layers.gssapi.SSP.GSS_Accept_sec_context`: called by the server, passing it a ``Context`` and optionally a token
27
+
28
+
They both return the updated Context, a token to optionally send to the server/client and a GSSAPI status code.
29
+
30
+
.. note::
31
+
32
+
You can typically use it in :class:`~scapy.layers.smbclient.SMB_Client`, :class:`~scapy.layers.smbserver.SMB_Server`, :class:`~scapy.layers.msrpce.rpcclient.DCERPC_Client` or :class:`~scapy.layers.msrpce.rpcserver.DCERPC_Server`.
33
+
Have a look at `SMB <smb.html>`_ and `DCE/RPC <dcerpc.html>`_ to get examples on how to use it.
34
+
35
+
Let's implement our own client that uses one of those SSPs.
36
+
37
+
Client
38
+
~~~~~~
39
+
40
+
First let's create the SSP. We'll take :class:`~scapy.layers.ntlm.NTLMSSP` as an example but the others would work just as well.
You can override the GSS-API ``req_flags`` when calling :func:`~scapy.layers.gssapi.SSP.GSS_Init_sec_context`, using values from :class:`~scapy.layers.gssapi.GSS_C_FLAGS`:
103
+
104
+
.. code:: python
105
+
106
+
sspcontext, token, status = clissp.GSS_Init_sec_context(None, None, req_flags=(
107
+
GSS_C_FLAGS.GSS_C_EXTENDED_ERROR_FLAG|
108
+
GSS_C_FLAGS.GSS_C_MUTUAL_FLAG|
109
+
GSS_C_FLAGS.GSS_C_CONF_FLAG# Asking for CONFIDENTIALITY
110
+
))
111
+
112
+
113
+
Server
114
+
~~~~~~
115
+
116
+
Implementing a server is very similar to a client but you'd use :func:`~scapy.layers.gssapi.SSP.GSS_Accept_sec_context` instead.
117
+
The client is properly authenticated when `status` is `GSS_S_COMPLETE`.
0 commit comments