Skip to content

Commit 62e335d

Browse files
authored
Kerberos improvements and SMB bugfix (session handling of a bad password) (#4597)
1 parent 45de3db commit 62e335d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

scapy/layers/kerberos.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
draft-ietf-kitten-iakerb-03
2020
- Kerberos Protocol Extensions: [MS-KILE]
2121
- Kerberos Protocol Extensions: Service for User: [MS-SFU]
22+
- Kerberos Key Distribution Center Proxy Protocol: [MS-KKDCP]
2223
2324
2425
.. note::
@@ -134,6 +135,7 @@
134135
_GSSAPI_SIGNATURE_OIDS,
135136
)
136137
from scapy.layers.inet import TCP, UDP
138+
from scapy.layers.smb import _NV_VERSION
137139

138140
# Typing imports
139141
from typing import (
@@ -2502,6 +2504,32 @@ def tcp_reassemble(cls, data, *args, **kwargs):
25022504
bind_bottom_up(TCP, KpasswdTCPHeader, sport=464)
25032505
bind_layers(TCP, KpasswdTCPHeader, dport=464)
25042506

2507+
# [MS-KKDCP]
2508+
2509+
2510+
class _KerbMessage_Field(ASN1F_STRING_PacketField):
2511+
def m2i(self, pkt, s):
2512+
val = super(_KerbMessage_Field, self).m2i(pkt, s)
2513+
if not val[0].val:
2514+
return val
2515+
return KerberosTCPHeader(val[0].val, _underlayer=pkt), val[1]
2516+
2517+
2518+
class KDC_PROXY_MESSAGE(ASN1_Packet):
2519+
ASN1_codec = ASN1_Codecs.BER
2520+
ASN1_root = ASN1F_SEQUENCE(
2521+
_KerbMessage_Field("kerbMessage", "", explicit_tag=0xA0),
2522+
ASN1F_optional(Realm("targetDomain", None, explicit_tag=0xA1)),
2523+
ASN1F_optional(
2524+
ASN1F_FLAGS(
2525+
"dclocatorHint",
2526+
"",
2527+
FlagsField("", 0, -32, _NV_VERSION).names,
2528+
explicit_tag=0xA2,
2529+
)
2530+
),
2531+
)
2532+
25052533

25062534
# Util functions
25072535

scapy/layers/smbclient.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ def __init__(self, smbsock, use_ioctl=True, timeout=3):
663663
self.ins = smbsock
664664
self.timeout = timeout
665665
if not self.ins.atmt.smb_sock_ready.wait(timeout=timeout):
666+
self.ins.atmt.session.sspcontext.clifailure()
666667
raise TimeoutError(
667668
"The SMB handshake timed out ! (enable debug=1 for logs)"
668669
)

0 commit comments

Comments
 (0)