mirror of
https://github.com/jakeotte/klist2ccache
synced 2026-08-09 12:42:04 +00:00
Merge pull request #2 from absolomb/main
Update dumping behavior to display ticket end and renewal time and skip expired tickets
This commit is contained in:
@@ -901,6 +901,7 @@ def cmd_dump(args):
|
||||
# ── Write ccache files ───────────────────────────────────────────────────
|
||||
written = []
|
||||
for i, ((logon_hex, account), tgt_text) in enumerate(zip(to_dump, tgt_texts), 1):
|
||||
print()
|
||||
logging.info("[%d/%d] %s (%s) ..." % (i, len(to_dump), account, logon_hex))
|
||||
if not tgt_text:
|
||||
logging.error(" No output for %s" % account)
|
||||
@@ -913,6 +914,20 @@ def cmd_dump(args):
|
||||
logging.error(" %s: session key is Credential Guard-protected (wrapped in VTL1); "
|
||||
"cannot export a usable ccache. Skipping." % account)
|
||||
continue
|
||||
|
||||
now = time.time()
|
||||
|
||||
if info["end_time"]:
|
||||
etime = datetime.fromtimestamp(info["end_time"]).isoformat()
|
||||
logging.info(" EndTime: %s", etime)
|
||||
|
||||
if info["renew_till"]:
|
||||
rtime = datetime.fromtimestamp(info["renew_till"]).isoformat()
|
||||
logging.info(" Renew Until: %s", rtime)
|
||||
if info["renew_till"] < now:
|
||||
logging.info(" Expired Ticket!")
|
||||
continue
|
||||
|
||||
safe_name = re.sub(r"[^\w@.-]", "_", "%s@%s" % (info["client"], info["realm"]))
|
||||
out_path = os.path.join(args.output_dir, safe_name + ".ccache")
|
||||
if os.path.exists(out_path):
|
||||
|
||||
@@ -426,6 +426,7 @@ def cmd_dump(args):
|
||||
|
||||
written = []
|
||||
for i, (logon_hex, account) in enumerate(to_dump, 1):
|
||||
print()
|
||||
logging.info("[%d/%d] Dumping TGT for %s (%s) ..." % (i, len(to_dump), account, logon_hex))
|
||||
tgt_text = _run_cmd(session, "klist tgt -li %s" % logon_hex)
|
||||
if not tgt_text:
|
||||
@@ -444,7 +445,20 @@ def cmd_dump(args):
|
||||
logging.error(" %s: session key is Credential Guard-protected (wrapped in VTL1); "
|
||||
"cannot export a usable ccache. Skipping." % account)
|
||||
continue
|
||||
|
||||
now = time.time()
|
||||
|
||||
if info["end_time"]:
|
||||
etime = datetime.fromtimestamp(info["end_time"]).isoformat()
|
||||
logging.info(" EndTime: %s", etime)
|
||||
|
||||
if info["renew_till"]:
|
||||
rtime = datetime.fromtimestamp(info["renew_till"]).isoformat()
|
||||
logging.info(" Renew Until: %s", rtime)
|
||||
if info["renew_till"] < now:
|
||||
logging.info(" Expired Ticket!")
|
||||
continue
|
||||
|
||||
safe_name = re.sub(r"[^\w@.-]", "_", "%s@%s" % (info["client"], info["realm"]))
|
||||
out_path = os.path.join(args.output_dir, safe_name + ".ccache")
|
||||
if os.path.exists(out_path):
|
||||
|
||||
Reference in New Issue
Block a user