samr 0.1.0

MS-SAMR Security Account Manager Remote Protocol client — enumerate users, groups, domains, aliases over \PIPE\samr with a full DCE/RPC surface (Connect/Enum/Open/Lookup)
Documentation

samr

Crates.io Docs.rs License: MIT

MS-SAMR (Security Account Manager Remote Protocol) client for Rust — full DCE/RPC surface for enumerating users, groups, domains, aliases and local administrators over the \PIPE\samr named pipe. Part of the icedracon offensive-AD ecosystem, extracted from dcerpc.

Status

0.1.0 — first stable release. Encoders and decoders live-validated against Windows Server 2016 → 2025. Wire byte-shape matches the spec samr.* NDR marshaling.

What it does

MS-SAMR is the RPC-over-SMB protocol Windows exposes for SAM database access. This crate wraps the opcode set relevant to offensive/defensive tooling:

Opcode Purpose
SamrConnect2 (57) / SamrConnect5 (64) Open a handle to the SAM server.
SamrLookupDomainInSamServer (5) Domain name → SID.
SamrEnumerateDomainsInSamServer (6) Iterate domains on the server.
SamrOpenDomain (7) Handle-open on a domain SID.
SamrEnumerateUsersInDomain (13) RID + sAMAccountName pairs.
SamrCloseHandle (1) Release any of the above handles.

Usage

# async fn ex() -> Result<(), Box<dyn std::error::Error>> {
use smb2_client::{client::Cred, SmbClient};

let mut smb = SmbClient::connect("10.10.10.20").await?;
smb.login_cred("10.10.10.20", "CORP", "administrator", Cred::Password("P@ssw0rd!")).await?;
smb.tree_connect("\\\\10.10.10.20\\IPC$").await?;

let file_id = smb.open_pipe("samr").await?;
let mut pipe = dcerpc::transport::SmbPipe::new(&mut smb, file_id);
pipe.bind(samr::samr_syntax()).await?;

// SamrConnect2 → handle to SAM server
let resp = pipe.call(samr::opnum::CONNECT2,
                     &samr::encode_connect2("\\\\10.10.10.20", 0x02000000)).await?;
// ... decode handle, walk domains, enumerate users
# Ok(()) }

Related icedracon crates

  • dcerpc — sealed DCE/RPC transport this crate rides on
  • smb2-client — SMB2 named-pipe transport
  • ntlmssp — NTLM sealed bind for authenticated pipes
  • windows-sddl — SID / SDDL used in the domain-lookup response
  • ADhammer — the AD security-assessment toolkit that originally shipped this code before extraction

Comparison

  • ms-samr (zer1t0, 6836 dl) — data-types only, no RPC surface.
  • This crate — full client with encoders + decoders for the enum/lookup/open flow, ready to plug into a dcerpc::SmbPipe.

License

MIT © 2026 zevs