#Windows Security #Reconnaissance #LDAP
Recon of LDAP (389, 636)
To retrieve an AD object or sub-objects so-called Distinguished Names (DN) are used to identify the object.
Raw LDAP queries can be difficult to understand. Here's a source on how to create your own: SpecterOps.io, An Introduction to Manual Active Directory Querying.
Anonymous bind
Anonymous LDAP Binding allows a client to connect and search AD without logging in. Typically, a root DSE enumeration is allowed for anonymous connections. However, extended LDAP queries to AD without authentication should be disabled, as they represent a potentially serious threat and data leak.
# Enumerate root DSE
ldapsearch -H ldap://$ip:389/ -x -s base -b "" "(objectClass=*)" "*" +
# Get sub-objects of DN object
ldapsearch -H ldap://$ip:389/ -x -s sub -b "$object_DN" "(objectClass=*)" "*" +
Authenticated bind
# Get sub-objects of DN object
ldapsearch -H ldap://$ip:389/ -x -D "$domain\\$user" -w $pass -s sub -b "$object_DN" "(objectClass=*)" "*" +
Automatic scans
# Enumerate AD data via LDAP
nmap --script ldap-rootdse,ldap-search $ip