Skip to main content

Crate ms_lsat

Crate ms_lsat 

Source
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:

OpnumNamePurpose
6LsarOpenPolicy2Get a policy handle (starting point for every other op)
14LsarLookupSidsSID → account name (RID-brute enumeration when SAMR is blocked)
15LsarLookupNamesName → SID (works before authentication in some configs)
57LsarLookupSids2 /Same as 14 but wide-string, PACKAGE-RPC-CONNECT capable
58LsarLookupNames2Same 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§

access
Common LSA policy-access flags.
opnum

Structs§

LookedUpName
One row of a LookupNames response: the resolved SID (or the domain SID + a RID sentinel) and its type.
LookedUpSid
One row of a LookupSids response: the resolved name (or empty) and its type.
LsatClient
Ergonomic LSAT client. Binds the interface over an already-open \lsarpc pipe, opens the policy handle lazily on the first lookup call.
PolicyHandle
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 a PRPC_SID pointer — that’s LsarLookupNames3 / 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.