LDAP Enumeration with ldapsearch & ldapdomaindump
windowstool
Summary
Query AD over LDAP with ldapsearch/netexec, then dump the whole directory to HTML with ldapdomaindump for offline review.
Walkthrough
Enumerate Active Directory objects over LDAP, anonymously or with credentials, and export a full domain dump for offline analysis.
Steps
- Find the naming contexts first with a base-scope query so you know the correct search base (
dc=...). - Run unauthenticated/authenticated
ldapsearchqueries filtered byobjectClass(user, person, dnsNode) to list accounts and DNS records. - Bind with credentials using
-D "<USER>@<TARGET>" -w '<PASS>'(ornxc ldap --query) to read restricted objects such as the MicrosoftDNS container. - Dump the entire directory to HTML with
ldapdomaindump, then reviewdomain_users_by_group.htmlfor group memberships and quick wins.
Commands
bash
ldapsearch -H ldap://<TARGET> -x -s base namingcontexts
bash
ldapsearch -x -H ldap://<IP> -b "dc=monitored,dc=htb" ldapsearch -x -H ldap://<IP> -b "dc=monitored,dc=htb" "(objectClass=user)" ldapsearch -x -H ldap://<IP> -b "dc=monitored,dc=htb" "(objectClass=person)"
bash
ldapsearch -x -H ldap://<IP> \ -D "<USER>@<TARGET>" \ -w '<PASS>' \ -b "CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb"
bash
nxc ldap <IP> -u <USER> -p '<PASS>' \ --query "(objectClass=dnsNode)" "CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb"
bash
ldapdomaindump -u '<TARGET>\operator' -p '<PASS>' <IP> -o ldap/