ms-pkca 0.1.0

PKINIT (RFC 4556) client for AD CS abuse — PA-PK-AS-REQ / PA-PK-AS-REP with X.509 cert and UnPAC-the-hash
Documentation

ms-pkca

Crates.io Docs.rs License: MIT

PKINIT (RFC 4556) client for Active Directory Certificate Services abuse, in Rust — PA-PK-AS-REQ / PA-PK-AS-REP with an X.509 client cert, Diffie-Hellman shared-secret KDF, and the UnPAC-the-hash primitive that lifts an NT hash out of PAC_CREDENTIAL_DATA returned in the AS-REP.

Status

0.1.0-dev — pre-alpha, not wire-compatible against a live KDC yet (AS-REP parse + paChecksum are the remaining pieces). Part of the icedracon Rust offensive AD ecosystem.

What it does

Once you have a client certificate — typically minted through an ESC1/ESC6/ESC9/ESC13/ESC14/ESC15 abuse chain via ms-icpr — ms-pkca turns that certificate into a Kerberos TGT. It builds a full PA-PK-AS-REQ from a PEM cert + RSA key (RFC 4556 §3.2.1 AuthPack + PKAuthenticator, wrapped in RFC 5652 SignedData + ContentInfo), performs MODP-1024 or MODP-2048 Diffie-Hellman, and runs the RFC 4556 §3.2.3.1 octet-string-to-key KDF to derive the AS-REP encryption key. When a PAC_CREDENTIAL_INFO is present, unpac_the_hash extracts the NT hash — the pass-the-hash-from-a-cert primitive.

Usage

use ms_pkca::{PkinitClient, unpac_the_hash};

let client = PkinitClient::new("EXAMPLE.COM", "dc01.example.com:88");
let cert = std::fs::read("client.pem")?;
let key  = std::fs::read("client.key")?;

let rep = client.request_tgt_with_cert(&cert, &key, "alice@example.com")?;

// 0.1.0-dev: take the built wire bytes yourself; the KDC round-trip
// lands in 0.2 once picky-krb's AS-REP path is fully plumbed.
let as_req_der: Vec<u8> = rep.debug_as_req_der;

// Once you have a decrypted PAC_CREDENTIAL_DATA blob from a AS-REP:
let nt_hash: [u8; 16] = unpac_the_hash(&decrypted_blob)?;
# Ok::<(), Box<dyn std::error::Error>>(())

What works / what does not (this version)

  • Working:
    • RFC 4556 §3.2.1 AuthPack + PKAuthenticator ASN.1 encoders
    • RFC 5652 SignedData + ContentInfo (minimal, hand-rolled on der)
    • PA-PK-AS-REQ full DER assembly from a PEM cert + RSA key
    • MODP-1024 (Oakley group 2) and MODP-2048 (group 14) Diffie-Hellman
    • RFC 4556 §3.2.3.1 octet-string-to-key KDF (SHA-1 / SHA-256)
    • PAC_CREDENTIAL_INFO header parse + NT-hash extraction from decrypted PAC_CREDENTIAL_DATA (heuristic NDR scan)
  • Stubbed / deferred:
    • No network I/O today — PkinitClient::request_tgt_with_cert returns the built DER in AsRepResult::debug_as_req_der
    • AS-REP parsing not wired, so ticket / session_key / pac_credential_info come back empty
    • paChecksum (Kerberos-layer concern) supplied by caller via BuildOptions
    • No PKCS#12 (.pfx) loader — pre-convert (openssl pkcs12 -in x.pfx -out x.pem -nodes)
    • No RSA key-transport (PkinitKeyDataKeyPack) branch — modern KDCs are DH-only

Related icedracon crates

Part of a 4-crate ADCS attack chain — template parsing all the way to a live PKINIT-derived TGT:

  • ms-crtd — parse pKICertificateTemplate LDAP attrs, emit ESC findings
  • ms-icpr — submit ESC1 CSRs to the CA over MS-ICPR / MS-WCCE
  • ms-pkca (this crate) — PKINIT the issued cert into a Kerberos TGT + UnPAC-the-hash
  • ms-kile-fast — RFC 6113 FAST armor for the AS-REQ / TGS-REQ

Together they aim for Certipy parity in pure Rust with an S-tier dep tree.

Dependencies

S-tier minimal: der, spki, x509-cert, const-oid, rsa, sha1, sha2, aes, cbc, num-bigint-dig, thiserror, rand_core. No serde_json, no rasn. CMS is stable enough that hand-rolling SignedData against der is cheaper than pulling in rasn-cms and its runtime.

The network feature (on by default) pulls picky-krb + picky-asn1(-der) for Kerberos AS-REQ/AS-REP encoders. Disable it for a pure-offline PA-PK-AS-REQ builder.

License

MIT (C) 2026 zevs