ms-dnsp 0.1.0

Pure-Rust parser and builder for the MS-DNSP dnsRecord blob stored in Active-Directory-integrated DNS zones.
Documentation
  • Coverage
  • 30.68%
    27 out of 88 items documented1 out of 18 items with examples
  • Size
  • Source code size: 31.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 550.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • icedracon

ms-dnsp

crates.io docs.rs

Parser and builder for the dnsRecord blob — how an Active-Directory-integrated DNS zone stores each resource record (MS-DNSP §2.3.2.2, DNS_RPC_RECORD). Pure Rust, no FFI, no network, no LDAP client of its own.

A dnsNode object under DC=<zone>,CN=MicrosoftDNS,DC=DomainDnsZones,… carries one multi-valued dnsRecord attribute; every value is one of these blobs — a 24-byte header plus type-specific data. Read them out of an LDAP search, hand them here.

use ms_dnsp::{DnsRecord, RecordData};

for value in entry.attr_values("dnsRecord") {
    let rec = DnsRecord::parse(value)?;
    match &rec.data {
        RecordData::A(ip)     => println!("A     {ip}  ttl={}", rec.ttl),
        RecordData::Srv { port, target, .. } => println!("SRV   {target}:{port}"),
        other                 => println!("{other:?}"),
    }
}

Building works the same way and is byte-for-byte round-trip stable:

let rec = DnsRecord::new(RecordData::A("10.0.0.5".parse()?)).with_ttl(600);
let blob = rec.to_bytes();

Covers

A, AAAA, NS, CNAME, PTR, SOA, MX, SRV, TXT, and DNS_TYPE_ZERO tombstones. Any other type is preserved verbatim as RecordData::Unknown, so a record this crate does not model still round-trips unchanged.

Both name encodings are handled: DNS_COUNT_NAME (length + label count + length-prefixed labels) and DNS_RPC_NAME.

Details that bite

  • dwTtlSeconds is big-endian; every other integer in the header is little-endian.
  • dwTimeStamp is hours since 1601-01-01 UTC, and 0 means the record is static and will never be scavenged — DnsRecord::timestamp_unix() and is_static() handle both.
  • Rank decides which copy of a record wins; authoritative zone data is rank::ZONE (0xF0).

Parsing never panics: every length byte is validated against the buffer before it is used.

Who this is for

  • Auditing AD-integrated DNS: who can update which zone, which records are unsecured, what the SRV topology exposes.
  • DFIR and inventory over an LDAP dump, with no Windows host in the loop.
  • Anything that has to write records back into AD without going through the DNS RPC server.

License

MIT