Skip to main content

Crate ms_scmr

Crate ms_scmr 

Source
Expand description

§ms-scmr — MS-SCMR (Service Control Manager Remote), pure-Rust client

Open the remote SCM over an authenticated \PIPE\svcctl SMB pipe, create a transient service whose binary path is an arbitrary command, start it (runs as LocalSystem), delete the service, and — for exec() — read the command’s captured output off C$. The canonical Windows admin-remote-execution primitive, without a Windows runtime.

Layered over the dcerpc crate: this crate owns the SCMR wire (opnums, NDR encoders/ decoders, handles, access masks), dcerpc provides the SMB-transport pipe + NDR helpers

  • RpcError/Syntax types.

§Dual-use rationale

SVCCTL is a defensive/DFIR/admin primitive as much as an attacker one: fleet-wide service inventory, remote debugger start/stop, IR containment (stop wuauserv), routine automation — anywhere a Windows admin drops to sc.exe today, a Rust process can do the same over a signed SMB session. That’s the extraction rule at play here.

§Status

v0.1.0 — CreateService → Start → Delete cycle for command execution, plus the exec() output-capture wrapper. Query/enum service state, RControlService, and the richer service-config surface are follow-ups on the 0.1 line (additive).

§Example

let res = ms_scmr::exec(client, "10.0.0.10", "whoami /all").await?;
println!("ran as LocalSystem: {}", res.ran);
if let Some(out) = res.output { println!("{out}"); }

Modules§

opnum

Structs§

ExecResult
The result of a remote exec: the SCM outcome plus captured stdout/stderr (if any).
ScHandle
A 20-byte SC_RPC_HANDLE (attributes u32 + 16-byte context uuid).
SvcctlClient
High-level SVCCTL client bound over an SMB \PIPE\svcctl.

Functions§

exec
psexec-style command execution over SVCCTL. Creates a service whose binary detaches the real work (start "" /b, so it survives the SCM tearing the service down), redirects its output to a temp file on the target, starts it as LocalSystem, deletes the service, then reads the output back over C$ (delete-on-close). The service and temp file are always cleaned up.
run
Run a command as LocalSystem over SVCCTL without capturing output — for side-effect commands (e.g. reg save) whose result is a file the caller reads separately. Returns the SCM start code. Requires the client to be tree-connected to IPC$. Detaches via start "" /b.
svcctl_syntax
The Service Control Manager Remote interface (v2.0).