ms-pkca 0.1.0-dev

PKINIT (RFC 4556) client — PA-PK-AS-REQ / PA-PK-AS-REP with X.509 cert + UnPAC-the-hash (pre-alpha)
Documentation

ms-pkca

STATUS: pre-alpha (0.1.0-dev). NOT wire-compatible yet.

PKINIT (RFC 4556) client for Active Directory Certificate Services abuse — PA-PK-AS-REQ / PA-PK-AS-REP with X.509 client cert, DH shared-secret KDF, and the UnPAC-the-hash primitive (extract NT hash from PAC_CREDENTIAL_DATA returned in the AS-REP).

Backend for ESC1 / ESC6 / ESC9 / ESC13 / ESC14 / ESC15 exploitation once the certificate has been minted (this crate does not attack AD CS itself; it turns a certificate into a TGT and, where possible, credentials).

What works in 0.1.0-dev

  • 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)

What is stubbed / deferred

  • No network I/O. PkinitClient::request_tgt_with_cert builds the request DER and returns it in AsRepResult::debug_as_req_der; it does not send anything to a KDC.
  • No AS-REP parsing yet, so AsRepResult.ticket / session_key / pac_credential_info are always empty. The 0.2 pass will wire a Kerberos stack in.
  • No paChecksum computation. The AS-REQ-body checksum is a Kerberos-layer concern; caller supplies it via BuildOptions.
  • No PKCS#12 (.pfx) loader. request_tgt_with_pfx returns Error::PfxUnsupported — convert to PEM (openssl pkcs12 -in x.pfx -out x.pem -nodes) and use the cert path.
  • No RSA key-transport (PkinitKeyDataKeyPack) branch — modern KDCs accept DH only.

Minimal 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")?;
// In 0.1.0-dev, take the wire bytes yourself:
let as_req_der: Vec<u8> = rep.debug_as_req_der;

// UnPAC-the-hash on a decrypted PAC_CREDENTIAL_DATA blob:
let nt_hash = unpac_the_hash(&decrypted_blob)?; // [u8; 16]

Dependencies

S-tier minimal: der, spki, x509-cert, const-oid, rsa, sha1, sha2, num-bigint-dig, thiserror, rand_core. No serde_json, no rasn, no picky-krb (deliberately — CMS is stable and hand-rolling it against der is cheaper than importing a whole runtime).

License

MIT.