ntds-parse
NTDS.dit-domain decode + crypto primitives for Rust. The layer between an ESE row walker and secretsdump.py-shaped output.
Part of the icedracon offensive-AD / DFIR ecosystem.
v0.2 — crypto inlined
The full offline-decryption chain runs in-tree:
SYSTEM hive → bootkey (16 bytes, from windows-secrets)
│
▼
unwrap_peklist(bootkey, PEKLIST_bytes) ──▶ PekList { keys: [PekKey; N] }
(SHA-256 KDF + AES-256-CBC for revision 3;
MD5 KDF + RC4 for legacy revision 2)
│
▼
decrypt_nt_hash(unicodePwd_bytes, &PekList, rid) ──▶ [u8; 16]
(AES-128-CBC unwrap with PEK[header.pek_index], IV = KeyMaterial
→ DES-ECB × 2 with keys derived from the account's RID)
Round-trip tests cover both PEK revisions and the full NT-hash unwrap chain end-to-end, verified against captured wire samples.
What's in v0.2
NtdsFile::open— ESE file-header validation (magic0x89ABCDEF, format version, page size, file-type).pek::unwrap_peklist— SHA-256/MD5-KDF + AES-256-CBC/RC4 decrypt of the encrypted PEKLIST blob.pek::PekList::parse_plaintext— decode the decrypted plaintext into indexedPekKeys; accepts AES-block zero-padding, rejects torn buffers.hash::decrypt_nt_hash— full 2-layer unwrap: AES-128-CBC + DES-ECB using RID-derived keys.hash::derive_des_keys_from_rid+hash::expand_des_key— the SAM/NTDS RID→DES key derivation, corrected for theout[0]parity-slot bug.uac::Uac— 22-field typed decode ofuserAccountControl+not_smartcard_only()+asreproast_eligible()convenience.sam::SamAccountType— enum decode withhas_password().
What v0.2 does not do (roadmap)
- Full ESE row walk. Iterating
datatableandlink_tableneeds a B-tree traversal + long-value / multi-value column reassembly. Wire the [EseBackend] trait tolibesedbFFI, theesedcrate, or wait for the standaloneese-parsercrate that's on the icedracon roadmap. - LM hash + supplementalCredentials (Kerberos AES / PBKDF2 keys, cleartext, etc.) — same crypto stack as NT hash; scope for v0.3.
Deps
aes · cbc · des · sha2 · md-5 · rc4 · cipher — all RustCrypto. Zero non-crypto deps. No optional features to configure; a call to unwrap_peklist + decrypt_nt_hash pulls the full stack.
Usage
use ;
let f = open?;
println!;
// 1. Unwrap the PEK using the SYSTEM hive bootkey (from `windows-secrets`)
let bootkey: = *b"boot_key_16bytes";
let peklist_bytes: = /* from datatable[Pek-List].pekList */ vec!;
let pek_list = unwrap_peklist?;
// 2. Decrypt one user's NT hash
let encrypted_nt: = /* from datatable[user].unicodePwd */ vec!;
let rid: u32 = 1105;
let nt_hash = decrypt_nt_hash?;
println!;
# Ok::
Related icedracon crates
lsass-parse— live-memory sibling (offline LSASS-minidump)windows-secrets— SYSTEM/SECURITY hive → bootkey, feedsunwrap_peklistsamr— live-RPC alternative- ADhammer — full driver
License
MIT © 2026 zevs