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
-EncodedCommandhelpers, 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 clearError::Unsupportedrather than panicking.
§NOT YET wired
- HTTP sign+seal (
multipart/encrypted; protocol="application/HTTP-SPNEGO-session-encrypted"). Blocks WinRM over plaintext 5985 with the defaultAllowUnencrypted=false. Use HTTPS (5986) meanwhile. - CredSSP transport —
WinRmClient::auth_credsspdrives the siblingcredsspcrate’sCredSspClientstate 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 viacredssp_auth::CredSspPump::kerberos— caller supplies aServiceTicket; that same pump then feedsWinRmClient::auth_credssp-style HTTP pumping (a top-levelauth_kerberos_credsspwrapper lands with the KDC transport in ms-kile). WSMV message encryption over the sealed CredSSP channel is still open — post-auth SOAP against aAllowUnencrypted=falsetarget is rejected until it lands. - Kerberos — same story, wire up via a picky-krb-based path later.
receive_streamreturns an immediately-Doneempty stream (real streaming needs the sign+seal layer above).upload_fileis currentlyUnsupportedfor 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 nowRe-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 ofntlmssp::Ntlm. - credssp_
auth - CredSSP over WinRM auth pump — a thin state machine on top of the sibling
credsspcrate. - error
- Error surface for the WinRM client.
- ps
- PowerShell helpers:
-EncodedCommandframing (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
MessageIDandSelectorSetland in byte-deterministic positions (unit-testable).
Structs§
- Chunk
- One decoded chunk pulled from a Receive response.
- Command
Id - Opaque WSMan
CommandId— bound to a specificShellId. - ShellId
- Opaque WSMan
ShellId(UUID string as reported by the server, without theuuid:prefix). - WinRm
Client - 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§
- Auth
Kind - Which SSP the client last authenticated with.
Functions§
- b64
- One-shot base64-encode helper — public because the
upload_filechoreography (once implemented) calls this from PS one-liner assembly.