Appearance
LDAP - 389 / 636 β
π Resources β
π Attributs β
userPrincipalNameβ Full login name (e.g., user@domain.lan)sAMAccountNameβ Legacy Windows login (e.g., DOMAIN\user)memberOfβ Lists the groups the user is a direct member oflastLogon/lastLogonTimestampβ Last login time (can help detect active accounts)pwdLastSetβ When the password was last changedservicePrincipalNameβ Used for Kerberos; if set, account is vulnerable to KerberoastingadminCountβ Set to1if the user is (or was) in a protected group like Domain AdminsobjectSid/objectGUIDβ Unique identifier of the object; useful for correlation or persistence
π Enumeration (No Auth) β
bash
nmap -n -sV --script "ldap* and not brute" $IPbash
# Query root DSE (fetch all operational attributes with '+')
ldapsearch -LLL -x -H ldap://$IP -s base -b "" "(objectClass=*)" +
# Get only namingContexts
ldapsearch -x -H ldap://$IP -s base -b '' '(objectClass=*)' namingContexts
# LDAPS (port 636)
ldapsearch -x -H ldaps://$IP -s base -b '' '(objectClass=*)'
# IF result : "Insufficient access" (you can't enumerate the base DC)
ldapsearch -x -H ldap://$IP -s base -b 'OU=GUESS_REAL_OU,DC=domain,DC=lan' '(objectClass=*)' # Point to a real OUπ Default OU β
You can guess some common OUs with tools like enum4linux or rpcclient by analyzing usernames, groups, or CN strings.
bash
# Common default or guessed OUs:
OU=Users
OU=Computers
OU=Domain Controllers
OU=IT
OU=Informatique
OU=HR
OU=RH
OU=Finance
OU=Achats
OU=Sales
OU=Staff
OU=Employees
OU=Adminsπ€ Enumerate Users / Groups β
bash
# List all users (format UPN)
ldapsearch -x -H ldap://$IP -D 'user@domain.lan' -w 'password' -b 'CN=Users,DC=domain,DC=lan'
ldapsearch -x -H ldap://$IP -D "DOMAIN\\user" -w 'password' -b "DC=domain,DC=lan" "(objectClass=user)" sAMAccountName descrption
ldapsearch -x -H ldap://$IP -D 'user' -w 'password' -b 'CN=Users,DC=domain,DC=lan'
# Administrators accounts
ldapsearch -x -H ldap://$IP -D 'DOMAIN\\username' -w 'password' -b "CN=Administrators,CN=Builtin,DC=domain,DC=lan"
# Search for a specific user
ldapsearch -x -H ldap://$IP -D "DOMAIN\\user" -w 'password' -b "DC=domain,DC=lan" "(sAMAccountName=john.doe)"bash
# List all groups
ldapsearch -x -H ldap://$IP -D "DOMAIN\\user" -w 'password' -b "DC=domain,DC=lan" "(objectClass=group)" cn member
# Get members of a specific group
ldapsearch -x -H ldap://$IP -D "DOMAIN\\user" -w 'password' -b "DC=domain,DC=lan" "(cn=Domain Admins)" memberπ Utils Queries β
bash
# List all computers in the domain (attributes: cn, dNSHostName, operatingSystem)
ldapsearch -LLL -x -H ldap://$IP -D "user@domain.lan" -w 'password' \
-b "DC=domain,DC=lan" "(objectClass=computer)" cn dNSHostName operatingSystem
# Find users with SPNs set (for Kerberoasting)
ldapsearch -LLL -x -H ldap://$IP -D "user@domain.lan" -w 'password' \
-b "DC=domain,DC=lan" "(&(objectClass=user)(servicePrincipalName=*))" sAMAccountName servicePrincipalName
# Find disabled accounts
ldapsearch -LLL -x -H ldap://$IP -D "user@domain.lan" -w 'password' \
-b "DC=domain,DC=lan" "(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))"
# List users with password never expiring
ldapsearch -LLL -x -H ldap://$IP -D "user@domain.lan" -w 'password' \
-b "DC=domain,DC=lan" "(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))"π Sensitive Groups (Domain Admins, RDP, ...) β
| Group | CN (Common Name) | Contexte / Location |
|---|---|---|
| Domain Admins | CN=Domain Admins | CN=Users,DC=domain,DC=lan |
| Enterprise Admins | CN=Enterprise Admins | CN=Users,DC=domain,DC=lan |
| Administrators (Builtin) | CN=Administrators | CN=Builtin,DC=domain,DC=lan |
| Account Operators | CN=Account Operators | CN=Builtin,DC=domain,DC=lan |
| Server Operators | CN=Server Operators | CN=Builtin,DC=domain,DC=lan |
| Backup Operators | CN=Backup Operators | CN=Builtin,DC=domain,DC=lan |
| Remote Desktop Users | CN=Remote Desktop Users | CN=Builtin,DC=domain,DC=lan |
| Print Operators | CN=Print Operators | CN=Builtin,DC=domain,DC=lan |
| Schema Admins | CN=Schema Admins | CN=Users,DC=domain,DC=lan |
| DnsAdmins | CN=DnsAdmins | CN=Users,DC=domain,DC=lan |
π§° Useful Tools β
bash
# ldap2json - dump LDAP info as JSON
python3 ldap2json.py -d 'domain.lan' -u 'user' -p 'password' --dc-ip $IP
# ldapdomaindump - full domain enumeration
pip3 install ldapdomaindump
ldapdomaindump -u 'domain\\user' -p 'password' -d domain.lan $IP
# bloodhound-python - gather data for BloodHound
bloodhound-python -u 'user' -p 'password' -d domain.lan -dc-ip $IP -c Allπ‘ Tips β
namingContextsto discover base DNs-LLLfor clean output, and-vfor verbose/debug(!objectClass=computer)to filter out machine accountsobjectCategory=personinstead ofobjectClass=userfor faster user queries- Wildcards allowed in filters:
(sAMAccountName=adm*) -Zto force StartTLS (port 389)