Skip to content

Commit

Permalink
additional printing
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAle98 committed Feb 26, 2024
1 parent a81e1a8 commit e473903
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions impacket/krb5/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def decrypt(cls, key, keyusage, ciphertext):
basic_ctext, mac = bytearray(ciphertext[:-cls.macsize]), bytearray(ciphertext[-cls.macsize:])
if len(basic_ctext) % cls.padsize != 0:
raise ValueError('ciphertext does not meet padding requirement')
print("")
print("basic_ctext")
print(len(basic_ctext))
for i in basic_ctext:
Expand All @@ -253,6 +254,7 @@ def decrypt(cls, key, keyusage, ciphertext):
print("padding")
for i in padding:
print(f"{hex(i)},",end="")
print("")
# basic_plaintext = basic_plaintext.replace(padding,b"\xff"*len(padding))
hmac = bytearray(HMAC.new(ki.contents, basic_plaintext, cls.hashmod).digest())
expmac = hmac[:cls.macsize]
Expand Down
16 changes: 10 additions & 6 deletions impacket/krb5/gssapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,19 @@ def unrotate(self, data, numBytes):
result = data[numBytes:] + data[:numBytes]
return result

def GSS_Wrap(self, sessionKey, data, sequenceNumber, direction = 'init', encrypt=True,keyUsage=KG_USAGE_INITIATOR_SEAL,confounder=None):
def GSS_Wrap(self, sessionKey, data, sequenceNumber, direction = 'init', encrypt=True,keyUsage=KG_USAGE_INITIATOR_SEAL,confounder=None, padding=None):
token = self.WRAP()

cipher = self.cipherType()

# Let's pad the data
pad = (cipher.blocksize - (len(data) % cipher.blocksize)) & 16
padStr = b'\xFF' * pad
data += padStr
if padding:
pad = len(padding)
padStr = padding
data += padStr
else:
# Let's pad the data
pad = (cipher.blocksize - (len(data) % cipher.blocksize)) & 15
padStr = b'\xFF' * pad
data += padStr

# The RRC field ([RFC4121] section 4.2.5) is 12 if no encryption is requested or 28 if encryption
# is requested. The RRC field is chosen such that all the data can be encrypted in place.
Expand Down

0 comments on commit e473903

Please sign in to comment.