Skip to main content

Crate winrm_pentest

Crate winrm_pentest 

Source
Expand description

winrm-pentest — async WinRM 2.0 (WS-Management) client aimed at offensive-security workflows: NTLM/CredSSP auth, remote PowerShell shell creation, -EncodedCommand execution, streaming stdout, and SMB-free file upload via base64-chunked <rsp:Send>.

§Status

Pre-alpha (0.1.0-dev). Compile-clean skeleton with:

  • Byte-deterministic WSMan envelope builders for Create / Command / Send / Receive / Signal / Delete (see wsman — round-trip tested).
  • Full NTLM Negotiate/Challenge/Authenticate driver over HTTP (via ntlmssp — no FFI, includes pass-the-hash), tested against a canned Windows challenge.
  • PowerShell -EncodedCommand helpers, including a deflate-then-b64 payload for scripts that overflow the 512 KB envelope cap.
  • Public API surface for the whole client (WinRmClient) with partial-impl bodies. Everything compiles; the pieces that need a live DC for iteration return a clear Error::Unsupported rather than panicking.

§NOT YET wired

  • HTTP sign+seal (multipart/encrypted; protocol="application/HTTP-SPNEGO-session-encrypted"). Blocks WinRM over plaintext 5985 with the default AllowUnencrypted=false. Use HTTPS (5986) meanwhile.
  • CredSSP transport — WinRmClient::auth_credssp drives the sibling credssp crate’s CredSspClient state machine over the HTTP auth pump (Authorization: CredSSP <b64(TSRequest)> / WWW-Authenticate: CredSSP …). NTLM path is wired end-to-end and tested against a mock listener. The Kerberos SspKind is exposed via credssp_auth::CredSspPump::kerberos — caller supplies a ServiceTicket; that same pump then feeds WinRmClient::auth_credssp-style HTTP pumping (a top-level auth_kerberos_credssp wrapper lands with the KDC transport in ms-kile). WSMV message encryption over the sealed CredSSP channel is still open — post-auth SOAP against a AllowUnencrypted=false target is rejected until it lands.
  • Kerberos — same story, wire up via a picky-krb-based path later.
  • receive_stream returns an immediately-Done empty stream (real streaming needs the sign+seal layer above). upload_file is currently Unsupported for the same reason.

§Minimal usage

use winrm_pentest::WinRmClient;

let mut cli = WinRmClient::connect("dc01.lab.local", 5986, true).await?;
cli.auth_ntlm("LAB\\Administrator", "P@ssw0rd!").await?;
let sh = cli.open_shell().await?;
let cmd = cli.run_command(&sh, "whoami", &[]).await?;
let _ = cli.receive_stream(&cmd).await?; // stub for now

Re-exports§

pub use error::Error;
pub use error::Result;
pub use ps::ExecResult;

Modules§

auth
HTTP-Negotiate NTLM handshake — the Authorization: Negotiate <b64> / WWW-Authenticate: Negotiate <b64> pump on top of ntlmssp::Ntlm.
credssp_auth
CredSSP over WinRM auth pump — a thin state machine on top of the sibling credssp crate.
error
Error surface for the WinRM client.
ps
PowerShell helpers: -EncodedCommand framing (mandatory UTF-16LE base64) and an opt-in deflate-then-b64 payload that expands via a [System.IO.Compression] one-liner.
wsman
WS-Management SOAP envelope builder — hand-rolled so MessageID and SelectorSet land in byte-deterministic positions (unit-testable).

Structs§

Chunk
One decoded chunk pulled from a Receive response.
CommandId
Opaque WSMan CommandId — bound to a specific ShellId.
ShellId
Opaque WSMan ShellId (UUID string as reported by the server, without the uuid: prefix).
WinRmClient
Async WinRM 2.0 client. One instance = one target + one HTTP-Keep-Alive connection (NTLM binds to the connection, so we cannot share it).

Enums§

AuthKind
Which SSP the client last authenticated with.

Functions§

b64
One-shot base64-encode helper — public because the upload_file choreography (once implemented) calls this from PS one-liner assembly.