Skip to content

Commit

Permalink
Fix show() on non-UTC Kerberos
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Feb 6, 2024
1 parent eae1567 commit ff96859
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions scapy/modules/ticketer.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def save(self, fname=None):
with open(self.fname, "wb") as fd:
return fd.write(bytes(self.ccache))

def show(self):
def show(self, utc=False):
"""
Show the content of a CCache
"""
Expand All @@ -382,7 +382,10 @@ def _to_str(x):
if x is None:
return "None"
else:
x = datetime.fromtimestamp(x)
x = datetime.fromtimestamp(
x,
tz=timezone.utc if utc else None
)
return x.strftime("%d/%m/%y %H:%M:%S")

for i, cred in enumerate(self.ccache.credentials):
Expand Down
2 changes: 1 addition & 1 deletion test/scapy/layers/kerberos.uts
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ with mock.patch('scapy.libs.rfc3961.os.urandom', side_effect=fake_random):
= Ticketer++ - Call show()

with ContextManagerCaptureOutput() as cmco:
t.show()
t.show(utc=True)
outp = cmco.get_output().strip()

print(outp)
Expand Down

0 comments on commit ff96859

Please sign in to comment.