Safe Rust wrapper around the Windows Local Security Authority (LSA)
Kerberos authentication package. Enumerate the current logon session's ticket
cache, retrieve the TGT bytes, submit KRB-CRED, and purge entries — without
handwriting LSA_STRING, KERB_*_REQUEST, or LsaFreeReturnBuffer calls.
Intended for AD tooling, DFIR, and Kerberos audit code that needs to talk to
LSA directly rather than shelling out to klist.
0.2 tested companion crate. LSA connection, Kerberos package lookup,
ticket-cache query, retrieval, submission, and purge paths are implemented on
top of win32-min; APIs may still evolve before 1.0. See the central
win32-min ecosystem map
for compatibility and maturity information.
Wraps the four LsaCallAuthenticationPackage messages that any real Kerberos
client tool ends up needing: KerbRetrieveTicketMessage,
KerbQueryTicketCacheMessage, KerbSubmitTicketMessage,
KerbPurgeTicketCacheMessage. The transport layer
(LsaConnectUntrusted / LsaLookupAuthenticationPackage("Kerberos") /
protocol-status propagation / response-buffer free) is done once, in RAII, so
callers only see typed TicketCacheInfo / KrbCred values. See
[MS-KILE] 3.4.5 and winnt.h for the underlying primitives.
use windows_lsa::{query_ticket_cache, retrieve_tgt};
fn main() -> windows_lsa::Result<()> {
// Enumerate the current logon session's ticket cache.
for t in query_ticket_cache(None)? {
println!("{} @ {}", t.server_name, t.realm_name);
}
// Pull the current TGT (raw encoded ASN.1 Ticket bytes for the current LUID).
let tgt = retrieve_tgt(None)?;
println!("TGT: {} bytes", tgt.encoded.len());
Ok(())
}Inventory the current logon session's Kerberos ticket metadata without exporting or modifying ticket material:
cargo run --example kerberos_cacheThe example uses an untrusted LSA connection and can legitimately return an
empty cache for a local-account session. See the ecosystem's
RESEARCH-WORKFLOWS.md
for the complete workflow set.
- Working:
LsaConnectUntrusted+LsaDeregisterLogonProcessvia RAIILsahandle.LsaLookupAuthenticationPackage("Kerberos").LsaCallAuthenticationPackagetransport, protocol-status propagation, and response-buffer free (LsaFreeReturnBuffer).KerbRetrieveTicketMessage— encoded TGT bytes for current or supplied LUID.KerbQueryTicketCacheMessage— strongly-typedTicketCacheInfoentries.KerbSubmitTicketMessage— inline header + KRB-CRED trailer with correctKerbCredOffset.KerbPurgeTicketCacheMessage— inline trailing UTF-16 SPN.zeroizeonKrbCredpayload.- Non-Windows compile: stub returns
Error::Unsupportedat every entry point.
- Stubbed / next milestone:
- Bytes returned by
retrieve_tgtare the raw ASN.1Ticket, not a fullKRB-CRED— re-submitting viasubmit_ticketrequires an external KRB-CRED wrapper. KerbRetrieveEncodedTicketMessage(per-SPN with target name) not yet exposed.KerbQueryTicketCacheEx2Message(session-key + client name) not yet exposed.- No live-DC integration tests —
#[cfg(windows)]smoke tests tolerate empty caches.
- Bytes returned by
win32-min— verified, dependency-free Win32 ABI foundation used by this crate.windows-sspi-shim— SSPI Negotiate ergonomics over Devolutionssspifor callers that wantseal/unsealrather than raw ticket bytes.windows-token— RAII tokens + impersonation; pair with LSA calls made under an alternate LUID.windows-scm— local Service Control Manager wrapper for the "run as SYSTEM" side of the same tooling.
Together these cover identity, authentication, telemetry, and local administration workflows for Windows security research and defensive tooling.
win32-min >= 0.1.2, < 0.2with onlylsa-authenabled.zeroizefor ticket payload cleanup andthiserrorfor the error taxonomy.- No async runtime or generated Windows bindings.
MIT © 2026 zevs