Expand description
ntds-parse — NTDS.dit-domain decode primitives.
Ntds.dit is Windows Active Directory’s on-disk copy of the domain: users, groups,
password hashes, computer accounts, GPO links. Physically it’s a Microsoft Extensible
Storage Engine (ESE / Jet Blue) database. Semantically the interesting rows sit in the
datatable and link_table tables, and the password material is encrypted with a chain
that starts at the SYSTEM hive’s boot key.
This crate is the NTDS-domain layer:
NtdsFile::open— validate the ESE file header (magic, page size, format version).pek::unwrap_peklist— SYSTEM bootkey + NTDSPEKLISTblob → the PEK (Password Encryption Key) that decrypts every hash in the datatable.hash::decrypt_nt_hash— encrypted NT-hash bytes (as they appear in theunicodePwdattribute) + PEK + RID → plaintext NT hash. Same shape for LM.uac— decodeuserAccountControlbits (disabled, dontrequirepreauth, notdelegated, trusteddelegation, useDesKeyOnly, etc.) into a boolean-typed struct.sam— decodesAMAccountTypenumeric values into a symbolic enum (NORMAL_USER_ACCOUNT, MACHINE_ACCOUNT, TRUST_ACCOUNT, GROUP_OBJECT, …).
§What this crate is not
Not an ESE row walker. Full datatable decode needs an ESE B-tree traversal plus long-
value / multi-value column reassembly — 3000+ LOC of file-format work. For v0.1 that lives
behind the EseBackend trait; downstream can plug in libesedb FFI, the esed crate,
or a from-scratch walker. What this crate guarantees is that once you have the raw
attribute bytes, the crypto and semantic decoders here are correct.
§Example
use ntds_parse::{NtdsFile, pek, hash};
// 1. Confirm this is a valid NTDS.dit
let f = NtdsFile::open("C:\\Windows\\NTDS\\ntds.dit")?;
println!("ESE format {}, page size {} bytes", f.format_version(), f.page_size());
// 2. Unwrap the PEK using the SYSTEM hive bootkey
let bootkey: [u8; 16] = *b"boot_key_16bytes"; // from windows-secrets::bootkey()
let peklist_bytes: Vec<u8> = /* from datatable[Pek-List].pekList */ vec![];
let pek = pek::unwrap_peklist(&bootkey, &peklist_bytes)?;
// 3. Decrypt one user's NT hash
let encrypted_nt: Vec<u8> = /* from datatable[user].unicodePwd */ vec![];
let rid = 1105u32;
let plaintext = hash::decrypt_nt_hash(&encrypted_nt, &pek, rid)?;
println!("NT hash: {}", hash::hex(&plaintext));Modules§
- hash
- Decryption of the encrypted NT / LM hash bytes as they appear in NTDS.dit
unicodePwdanddbcsPwdattributes. - pek
- PEK (Password Encryption Key) unwrap — the crypto chain that turns a
PEKLISTrecord from thedatatableinto the AES/RC4 key that decrypts every hash column in NTDS.dit. - sam
- Decode of
sAMAccountType— the numeric object-class field. - uac
- Decode of
userAccountControl— the bitfield every AD account carries.
Structs§
- Ntds
File - A minimally-parsed NTDS.dit — enough to confirm the file is a valid ESE database and
expose its format metadata. Full row iteration is the caller’s job via
EseBackend.
Enums§
- Error
- Errors this crate returns.
Traits§
- EseBackend
- Trait for pluggable ESE row iteration — implement this to plug in a backend like
libesedbFFI, the pure-Rustesedcrate, or an in-tree walker. This crate doesn’t ship a backend in v0.1; the decoders (pek/hash/uac/sam) are what you use once you have raw attribute bytes from any backend.