Skip to main content

Crate dpapi_offline

Crate dpapi_offline 

Source
Expand description

Offline Windows DPAPI decryption — a DonPAPI/dploot-class core in pure Rust. No FFI, no live host: point it at files copied off disk.

  • masterkey — parse a user masterkey file and decrypt it from the user’s password + SID.
  • blob — parse a DPAPI_BLOB (CryptProtectData output) and decrypt it with a masterkey.
  • crypto — the underlying primitives.

§VALIDATION STATUS (read this)

This is the one crate in the ADhammer set that is a from-scratch crypto build, not an extraction of already-live code. Its honesty bar is therefore explicit:

  • Primitives — VALIDATED. PBKDF2-HMAC-SHA1 (RFC 6070), HMAC-SHA1 (RFC 2202) and HMAC-SHA512 (RFC 4231) are checked against published known-answer vectors in crypto’s tests — a genuine external oracle, not a self-round-trip.

  • Parsers — VALIDATED (structure). Deterministic layout tests for the masterkey file, masterkey subfield, and DPAPI_BLOB, plus truncation-safety.

  • Masterkey decrypt chain — VALIDATED (0.1.2, 2026-08-31). The full parser + ms_derive_key + AES256-CBC + HMAC-verify chain is exercised on every test run against a deterministic KAT (KAT_MK_SUBFIELD in masterkey::tests). 0.1.2 rebuilt the KAT from synthetic throwaway credentials via docs/synthetic_kat.py — earlier 0.1.1 embedded values derived from a real lab masterkey (Administrator on the icedracon testlab) and was yanked to stop the credential-material distribution; the synthetic KAT still exercises byte-oracle equivalence with impacket 0.14 dpapi.py because it uses the same algorithm that impacket implements — but nothing in the fixture maps back to a real account.

    The masterkey chain itself was proved correct against a real Windows Server 2025 domain Administrator masterkey during the 0.1.1 development cycle; that experiment is what discovered 0.1.0’s PBKDF2 used the RFC 8018 formulation, while Windows DPAPI uses a non-standard variant that feeds the running XOR back into the PRF at every round (ms_derive_key). 0.1.1+ routes every masterkey decrypt through that variant, adds MD4

    • Protected-Users pre-key derivations, and unlock_masterkey handles standalone, pre-2019 domain-joined, and 2019+ domain-joined / Protected-Users accounts transparently. Operators can re-run the live byte-oracle themselves via the ignored test_real_masterkey / test_real_masterkey_with_pwdkey tests + DPAPI_MK_FILE=… / DPAPI_MK_PWDKEY=… env vars.
  • Blob decrypt chain — NOT YET VALIDATED end-to-end. The blob derivation follows MS-DPAPI and impacket, but has not been run against a real Windows-generated blob yet — validate the same way: run impacket dpapi.py credential/vault against the same bytes as the byte-oracle.

Re-exports§

pub use blob::DpapiBlob;
pub use masterkey::MasterKey;
pub use masterkey::MasterKeyFile;

Modules§

blob
DPAPI data-blob (DPAPI_BLOB) parsing and decryption.
crypto
DPAPI crypto primitives. These are the parts validated against published RFC known-answer vectors (see the tests) — PBKDF2-HMAC-SHA1 (RFC 6070) and HMAC (RFC 2202 / 4231). The DPAPI-specific derivation that uses them lives in masterkey/blob.
masterkey
DPAPI user masterkey file parsing and decryption.

Enums§

DpapiError
Errors from parsing or decrypting DPAPI structures.

Functions§

unlock_masterkey
Convenience: decrypt a masterkey file’s masterkey from a password + SID. Tries all three pre-key derivations in this order — standalone SHA1, domain MD4, Protected-Users PBKDF2- SHA256 — and returns the first that HMAC-verifies. On a Server 2019+ domain admin the Protected-Users variant is what wins; on an old Server 2012 standalone box it’s the SHA1 variant. Caller doesn’t have to know which category the account is in.