msldap-ext
Encoder/decoder for the MS-ADTS LDAP extension controls that mainstream Rust
LDAP clients (ldap3, native_tls_ldap, …) do not ship. Built for
offensive-AD tooling that has to page through millions of objects, walk
tombstones, replicate incrementally with DirSync, or slice
nTSecurityDescriptor by SD_FLAGS — all the things impacket / ldap3.py /
ldapdomaindump do today with hand-crafted BER.
Status
0.1.0-dev — pre-alpha, expect breaking changes before 0.1.0. Part of
the icedracon Rust offensive AD ecosystem.
What it does
Pure BER control-value codecs for the six MS-ADTS controls an attacker
actually reaches for. The crate does not open sockets — it produces the
byte blob you feed into ldap3::Ldap::search_ext (or any LDAP transport) as
the controlValue of a Control SEQUENCE, and decodes the response-side
control value back into a typed struct.
| OID | Control | Spec | Where it shows up |
|---|---|---|---|
1.2.840.113556.1.4.319 |
Paged Results | RFC 2696 | Any AD search past MaxPageSize (1000) |
1.2.840.113556.1.4.529 |
ExtendedDN | MS-ADTS §3.1.1.3.4.1.5 | objectGUID + objectSid inline with DN |
1.2.840.113556.1.4.801 |
SD_FLAGS | MS-ADTS §3.1.1.3.4.1.11 | Read owner/DACL/SACL slices of nTSecurityDescriptor |
1.2.840.113556.1.4.417 |
ShowDeleted | MS-ADTS §3.1.1.3.4.1.14 | Include tombstones (deleted-object recovery) |
1.2.840.113556.1.4.841 |
DirSync | MS-ADTS §3.1.1.3.4.1.3 | Incremental replication of a naming context |
2.16.840.1.113730.3.4.9 |
VLV | draft-ietf-ldapext-ldapv3-vlv | Virtual List View (byOffset only) |
Hand-rolled BER (src/ber.rs, ~130 LOC) instead of pulling rasn — the
control values here only exercise SEQUENCE / INTEGER / OCTET STRING / one
context-specific tag, and this keeps the dep graph flat (uuid, thiserror).
Usage
use ;
// First page: encode a Paged Results control asking for 1000 rows.
let value = new.encode;
// -> pass (PAGED_RESULTS_OID, is_critical = true, Some(value))
// into ldap3::Ldap::search_ext as the request control.
// Server returns a control with the same OID. Decode its value:
let resp = decode?;
if !resp.is_end
# Ok::
What works / what does not (this version)
- Working
PagedResults— full round-trip (encode + decode, initial + with-cookie).SdFlags— encode/decode plusowner_dacl()/sacl()/all()helpers.DirSyncControl— encode/decode, request-side flag constants.ExtendedDn— request encode; response-string parser handles both<GUID=…>;<SID=…>;DNand<GUID=…>;DNforms, hex and standard GUID.ShowDeleted— marker type;encode()returns[](caller omitscontrolValue).VirtualListView—byOffsetvariant encodes.
- Stubbed / partial
- VLV
greaterThanOrEqualtarget — no method yet. - VLV response decoder — not written; consumer parses
contextIDmanually. - DirSync response OID (
1.2.840.113556.1.4.842) — shares wire shape with the request, soDirSyncControl::decodehandles both; a distinct response type would be clearer. ExtendedDnSID — response parser keeps the raw"S-1-5-…"string; binary SID decode is deferred to anms-dtypcompanion.- BER long-length encode > 4 bytes — refused. Fine for control values.
- VLV
- Not planned for 0.1.0
- Property-based round-trip tests, live-DC integration harness,
no_std.
- Property-based round-trip tests, live-DC integration harness,
Related icedracon crates
ms-even6— MS-EVEN6 EventLog Remoting v6 client + BinXml decoder (remote log pulls over\pipe\eventlog).ms-tds— TDS 7.4 client for Microsoft SQL Server with NTLM login and pentest primitives.
Together the three cover the LDAP / EventLog / MSSQL data-plane primitives that Python + impacket dominate today.
License
MIT (c) 2026 zevs