Skip to content

Commit 96e215b

Browse files
committed
PEP8 fixes
1 parent f35faee commit 96e215b

File tree

4 files changed

+165
-110
lines changed

4 files changed

+165
-110
lines changed

scapy/layers/kerberos.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,7 +5100,7 @@ def GSS_Init_sec_context(
51005100
# Update UPN (could have been canonicalized)
51015101
self.UPN = res.upn
51025102

5103-
# Store TGT,
5103+
# Store TGT,
51045104
self.TGT = res.asrep.ticket
51055105
self.TGTSessionKey = res.sessionkey
51065106
else:
@@ -5134,7 +5134,9 @@ def GSS_Init_sec_context(
51345134
Context.STSessionKey = self.KEY
51355135

51365136
if Context.flags & GSS_C_FLAGS.GSS_C_DELEG_FLAG:
5137-
raise ValueError("Cannot use GSS_C_DELEG_FLAG when passed a service ticket !")
5137+
raise ValueError(
5138+
"Cannot use GSS_C_DELEG_FLAG when passed a service ticket !"
5139+
)
51385140

51395141
# Save ServerHostname
51405142
if len(self.ST.sname.nameString) == 2:
@@ -5199,16 +5201,14 @@ def GSS_Init_sec_context(
51995201
# )
52005202
# )
52015203

5202-
52035204
# Build and encrypt the full KRB_Authenticator
52045205
ap_req.authenticator.encrypt(
52055206
Context.STSessionKey,
52065207
KRB_Authenticator(
52075208
crealm=crealm,
52085209
cname=PrincipalName.fromUPN(self.UPN),
52095210
cksum=Checksum(
5210-
cksumtype="KRB-AUTHENTICATOR",
5211-
checksum=authenticator_checksum
5211+
cksumtype="KRB-AUTHENTICATOR", checksum=authenticator_checksum
52125212
),
52135213
ctime=ASN1_GENERALIZED_TIME(now_time),
52145214
cusec=ASN1_INTEGER(0),

scapy/layers/msrpce/msnrpc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def establish_secure_channel(
676676
:param mode: one of NETLOGON_SECURE_CHANNEL_METHOD. This defines which method
677677
to use to establish the secure channel.
678678
:param UPN: the UPN of the computer account name that is used to establish
679-
the secure channel. (e.g. [email protected])
679+
the secure channel. (e.g. WIN10$@domain.local)
680680
:param DC_FQDN: the FQDN name of the DC.
681681
682682
The function then requires one of the following:
@@ -687,6 +687,10 @@ def establish_secure_channel(
687687
:param ssp: a KerberosSSP to use (in Kerberos mode)
688688
"""
689689
computername, domainname = _parse_upn(UPN)
690+
# We need to normalize here, since the functions require both the accountname
691+
# and the normal (no dollar) computer name.
692+
if computername.endswith("$"):
693+
computername = computername[:-1]
690694

691695
if mode == NETLOGON_SECURE_CHANNEL_METHOD.NetrServerAuthenticate3:
692696
if ssp or KEY:
@@ -858,7 +862,11 @@ def establish_secure_channel(
858862
ndrendian=self.ndrendian,
859863
)
860864
)
861-
if netr_server_authkerb_response.status != 0:
865+
if (
866+
NetrServerAuthenticateKerberos_Response
867+
not in netr_server_authkerb_response
868+
or netr_server_authkerb_response.status != 0
869+
):
862870
# An error occured
863871
netr_server_authkerb_response.show()
864872
raise ValueError("NetrServerAuthenticateKerberos failed !")

scapy/layers/spnego.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,15 +705,14 @@ def from_cli_arguments(
705705
if ST is None and ccache is not None:
706706
# In this case, load the KerberosSSP from ccache
707707
from scapy.modules.ticketer import Ticketer
708-
708+
709709
# Import into a Ticketer object
710710
t = Ticketer()
711711
t.open_ccache(ccache)
712712

713713
# Look for the ticketer that we'll use
714714
raise NotImplementedError
715715

716-
717716
ssps.append(t.ssp())
718717
elif ST is None:
719718
# In this case, KEY is supposed to be the user's key.

0 commit comments

Comments
 (0)