Expand description
MS-LSAT — Local Security Authority (Translation) Remote Protocol.
Windows exposes LSA name↔SID lookup services over \PIPE\lsarpc and (some) LSA
policy queries. The most common opnums pentesters + defenders actually use:
| Opnum | Name | Purpose |
|---|---|---|
| 6 | LsarOpenPolicy2 | Get a policy handle (starting point for every other op) |
| 14 | LsarLookupSids | SID → account name (RID-brute enumeration when SAMR is blocked) |
| 15 | LsarLookupNames | Name → SID (works before authentication in some configs) |
| 57 | LsarLookupSids2 / | Same as 14 but wide-string, PACKAGE-RPC-CONNECT capable |
| 58 | LsarLookupNames2 | Same as 15 but wide-string |
Rides an authenticated (or in some configs, anonymous) SMB pipe.
§What this crate provides in v0.1
Wire encoders + decoders for LsarOpenPolicy2, LsarLookupSids2, LsarLookupNames2,
and LsarClose, plus a small LsatClient wrapper that binds the interface over
dcerpc::transport::SmbPipe and exposes ergonomic lookup_sids(&[Sid]) → Vec<Name>
and lookup_names(&[&str]) → Vec<Sid> methods.
§Byte-format
Encoders match impacket’s lsat.* / lsad.* NDR marshaling (byte-verified against
impacket wire captures on Server 2016/2019/2022/2025). The lookup response layouts are
the ones that require the most care — see the module docs on decode_lookup_sids2
and decode_lookup_names2 for the pointer-shape.
Modules§
Structs§
- Looked
UpName - One row of a LookupNames response: the resolved SID (or the domain SID + a RID sentinel) and its type.
- Looked
UpSid - One row of a LookupSids response: the resolved name (or empty) and its type.
- Lsat
Client - Ergonomic LSAT client. Binds the interface over an already-open
\lsarpcpipe, opens the policy handle lazily on the first lookup call. - Policy
Handle - A 20-byte RPC context handle (attributes u32 + 16-byte GUID). Same shape as SAMR’s.
Enums§
- SidType
- SID-name-use enum values ([MS-LSAT] §2.2.13).
Functions§
- decode_
lookup_ names2 - Decode a LsarLookupNames2 response. Response =
LSAPR_TRANSLATED_SIDS_EX(v2, not v3): each entry carries{ Use: u16, RelativeId: u32, DomainIndex: i32, Flags: u32 }with the RID inline (NOT aPRPC_SIDpointer — that’sLsarLookupNames3/ opnum 68). We reconstruct the full SID by concatenating the referenced-domain SID with the RID. - decode_
lookup_ sids2 - Decode a LsarLookupSids2 response into per-input rows.
- encode_
lookup_ names2 - LsarLookupNames2(PolicyHandle, Count, Names, [out]RefDomains, [in,out]TranslatedSids, LookupLevel, [in,out]MappedCount, LookupOptions, ClientRevision).
- encode_
lookup_ sids2 - LsarLookupSids2(PolicyHandle, SidEnumBuffer, [out]RefDomains, [in,out]Names, LookupLevel, [in,out]MappedCount, LookupOptions, ClientRevision).
- encode_
open_ policy2 - LsarOpenPolicy2(SystemName [in,unique,string], ObjectAttributes [in], DesiredAccess [in])
- lsat_
syntax - The LSAT interface (v0.0). Same UUID as the LSA-Directory (LSAD) interface.