Expand description
ntlm-relay — NTLM relay-chain primitives, focused on the HTTP-side of the ESC8 / ESC11 AD CS relay.
§What this crate is
The reusable building blocks a Rust NTLM-relay driver needs on the target side of the
chain — the CA / LDAP / HTTP server the victim’s captured NTLM will be forwarded to.
The victim-listener side (SMB server, LDAP server, HTTP server) is a matter for the
transport crates (e.g. smb2-client exposes a
server::RelayConn); this crate provides the outbound pieces that turn a Type1 → Type3
opaque forward into an issued certificate.
§Included primitives
HttpsClient— minimal keep-alive HTTP/1.1 over rustls,insecureflag for the ubiquitous self-signed AD CS Web Enrollment endpoint.parse_ntlm_challenge— extract the Type-2 blob out ofWWW-Authenticate: NTLM <b64>.cert_request_form— build theMode=newreq&CertRequest=…&CertAttrib=…body the/certsrv/certfnsh.asphandler expects.parse_request_id— scrape theReqID=<n>the CA emits aftercertfnsh.aspreturns.base64_encode/base64_decode— the base64 subset needed by the ESC8 flow, so the crate depends onrustlsandtokioonly.
§ESC8 flow, end-to-end
victim SMB ──Type1──▶ your listener ──Type1──▶ HttpsClient.send("POST /certsrv/certfnsh.asp",
Authorization: NTLM Type1)
◀── 401 WWW-Authenticate: NTLM Type2
victim SMB ◀─Type2── your listener ◀─Type2──┘
victim SMB ──Type3──▶ your listener ──Type3──▶ HttpsClient.send("POST /certsrv/certfnsh.asp",
Authorization: NTLM Type3,
Body: cert_request_form(csr, tmpl))
◀── 200 OK, body contains ReqID=<n>
attacker ─────────────────────────────────────▶ HttpsClient.send("GET /certsrv/certnew.cer?ReqID=<n>")ESC11 (MS-ICPR over ncacn_ip_tcp) uses the same Type1/Type2/Type3 shape but on a
DCE/RPC bind, not HTTP — see the dcerpc crate’s
icpr module and its bind_relay_start / bind_relay_finish methods for the outbound
side of that variant.
§What this crate is not
Not a batteries-included relay driver — no SMB victim listener, no LDAP
msDS-KeyCredentialLink writer, no argument parsing, no target-selection
auto-pilot. The full driver lives in ADhammer, composing this crate with
smb2-client, dcerpc, ntlmssp, windows-sddl, and ms-pac-forge.
If you’re building your own relay driver, wire these primitives to your
listener of choice.
Re-exports§
pub use certsrv::Esc8Step1;pub use certsrv::EscCertsrvChain;pub use ldap_rbcd::build_rbcd_clear;pub use ldap_rbcd::build_rbcd_write;pub use ldap_rbcd::ModifyOp;pub use ldap_rbcd::RbcdWrite;pub use ldap_rbcd::ATTR_ALLOWED_TO_ACT_ON_BEHALF;
Modules§
- certsrv
- ESC8 — AD CS Web Enrollment relay chain.
- ldap_
rbcd - RBCD-write payload primitives for an LDAP-relay backend.
Structs§
Functions§
- base64_
decode - base64_
encode - cert_
request_ form - Build the form-encoded body AD CS Web Enrollment expects.
csr_pemis the PEM-armored PKCS#10. - parse_
ntlm_ challenge - Extract the NTLM Type-2 (base64) from a single
WWW-Authenticateheader value. - parse_
ntlm_ challenge_ all - Extract the NTLM Type-2 from any of the given
WWW-Authenticateheader values (in the order the server sent them). Use this overparse_ntlm_challengewhen the response may split schemes across multiple header lines (IIS does). - parse_
request_ id - Extract the certificate Request ID from the ASP response HTML. AD CS emits
ReqID=<n>in alocation.href="certnew.cer?ReqID=..."line or similar.