コンテンツにスキップ

LDAPDomainDump

LDAPDomainDump is a Python tool for extracting and analyzing Active Directory information via LDAP. It queries domain controllers to enumerate users, computers, groups, policies, and trust relationships, exporting results in multiple formats for both interactive analysis and scripting workflows.

pip install ldapdomaindump
git clone https://github.com/dirkjanm/ldapdomaindump.git
cd ldapdomaindump
pip install -r requirements.txt
python setup.py install
ldapdomaindump --help
ldapdomaindump -u 'DOMAIN\username' -p 'password' ldap://192.168.1.10
ldapdomaindump -u 'DOMAIN\username' -p 'password' ldaps://192.168.1.10
ldapdomaindump -u '' -p '' ldap://192.168.1.10
OptionUsageExample
-uDomain username-u 'DOMAIN\user' or -u 'user@domain.com'
-pPassword-p 'password123'
-at NTLMNTLM hash authentication-at NTLM -hashes lm:nt
LDAP (unencrypted)ldap:// protocolldap://10.0.0.5
LDAPS (SSL/TLS)ldaps:// protocolldaps://10.0.0.5
AnonymousEmpty credentials-u '' -p ''

LDAPDomainDump creates multiple files for each data type:

FileFormatPurpose
domain_users.htmlHTML reportInteractive user enumeration
domain_users.jsonJSON dataProgrammatic parsing
domain_users.grepGrep-friendlyCLI text processing
domain_computers.htmlHTML reportSystem inventory
domain_computers.jsonJSON dataMachine enumeration
domain_computers.grepGrep-friendlyOS/patch analysis
domain_groups.htmlHTML reportGroup memberships
domain_groups.jsonJSON dataMembership parsing
domain_groups.grepGrep-friendlyGroup extraction
domain_policy.htmlHTML reportPassword policies
domain_policy.jsonJSON dataPolicy data
domain_policy.grepGrep-friendlyPolicy attributes
domain_trusts.htmlHTML reportForest/domain trusts
domain_trusts.jsonJSON dataTrust relationships
domain_trusts.grepGrep-friendlyTrust enumeration

Open in browser for interactive exploration:

firefox domain_users.html
# Sort by columns, search, view descriptions

Parse with tools like jq:

jq '.users[] | select(.userAccountControl | contains("NORMAL_ACCOUNT"))' domain_users.json

Process with grep, awk, sed:

grep "ADMIN" domain_groups.grep
ldapdomaindump -u 'DOMAIN\user' -p 'pass' -o /tmp/dump ldap://10.0.0.5
# HTML only
ldapdomaindump -u 'DOMAIN\user' -p 'pass' --no-json --no-grep ldap://10.0.0.5

# JSON only
ldapdomaindump -u 'DOMAIN\user' -p 'pass' --no-html --no-grep ldap://10.0.0.5

# Grep only
ldapdomaindump -u 'DOMAIN\user' -p 'pass' --no-html --no-json ldap://10.0.0.5
ldapdomaindump -u 'DOMAIN\user' -p 'pass' -d '|' ldap://10.0.0.5
# Changes delimiter from default to pipe character
grep "Domain Admins" domain_groups.grep
grep -i "admin" domain_users.grep
grep "DISABLED" domain_users.grep
grep "DONT_EXPIRE_PASSWORD" domain_users.grep

Extract Description Fields (Common Loot Location)

Section titled “Extract Description Fields (Common Loot Location)”
grep "Description:" domain_users.grep
grep -i "password\|pwd\|pass" domain_users.grep
grep "1601\|1980\|2000" domain_users.grep
# Look for ancient timestamps
grep -i "svc\|service\|managed service" domain_users.grep
grep "Windows Server" domain_computers.grep
grep "Windows 10" domain_computers.grep
grep "Server 2019" domain_computers.grep
OptionUsage
-uUsername (domain\user format)
-pPassword
-oOutput directory (default: current)
-rReferral host for multi-domain environments
-at NTLMAuthentication type (NTLM)
-hashesLM:NT hashes instead of password
--no-htmlSkip HTML report generation
--no-jsonSkip JSON export
--no-grepSkip grep-friendly format
-dField delimiter for grep output
--dns-tcpUse TCP for DNS queries
# Open HTML reports in browser
firefox domain_users.html
firefox domain_groups.html
firefox domain_policy.html
# Get all user emails
jq -r '.users[] | .mail' domain_users.json | grep -v null

# Find users without password expiration
jq -r '.users[] | select(.userAccountControl | contains("DONT_EXPIRE_PASSWORD")) | .sAMAccountName' domain_users.json

# List all privileged groups
jq -r '.groups[] | select(.sAMAccountName | contains("Admin")) | .cn' domain_groups.json
# Find nested group memberships
grep -E "^cn=.*,cn=Users" domain_groups.grep

# Extract computer names and OS
awk -F'|' '{print $1,$3}' domain_computers.grep

# Search descriptions for sensitive info
grep -i "backup\|password\|key\|secret" domain_users.grep
# Find users in sensitive groups
for group in "Domain Admins" "Enterprise Admins" "Schema Admins"; do
  echo "=== $group ==="
  grep "$group" domain_groups.grep
done
# Combine ldapdomaindump JSON with BloodHound ingestor
# Export users and groups to BloodHound format for visualization
# Use ldapdomaindump to enumerate, then spray with CME
cme smb 10.0.0.0/24 -u 'user' -p 'pass' --shares
# Use enumerated usernames with GetNPUsers.py
python GetNPUsers.py -usersfile users.txt DOMAIN/
# Convert JSON output to BloodHound ingestor CSV format
jq -r '.users[] | [.cn, .memberOf[]] | @csv' domain_users.json
# Verify LDAP port is open
nmap -p 389,636 10.0.0.5

# Check firewall rules blocking LDAP
# Try LDAPS on 636 instead: ldaps://10.0.0.5
# Verify username format (DOMAIN\user or user@domain.com)
# Test with known valid account
# Check if account is locked or disabled
# Increase query timeout (depends on domain size)
# Try connecting directly to a specific DC
# Reduce scope with custom queries if supported
# Some objects may require higher privileges
# Try with Domain Admin or Enterprise Admin account
# Verify user has LDAP read permissions
# Verify LDAP connection successful
# Check output directory permissions
# Try specifying explicit output directory: -o /tmp/ldap_dump
  • Use encrypted connections (LDAPS on port 636) when possible to avoid credential sniffing
  • Test with null sessions first to determine what anonymous LDAP access reveals
  • Archive results for offline analysis and comparison across time
  • Cross-reference outputs between different formats to verify data integrity
  • Sanitize sensitive data before sharing reports with third parties
  • Document enumeration scope (date, credentials used, domain targeted)
  • Monitor for detection - LDAP enumeration may trigger security alerts in mature environments
  • Combine with other tools - use results as input for attack chain planning
  • Review descriptions carefully - often contain passwords, notes, legacy system info
  • Track stale accounts - old accounts may still have high privileges
ToolPurpose
windapsearchLDAP enumeration alternative with different output options
ADFindWindows-based AD enumeration (Windows only)
ldapsearchOpenLDAP CLI tool for manual queries
enum4linux-ngMulti-protocol enumeration including LDAP
BloodHoundAD visualization and attack path analysis
CrackMapExecMulti-protocol post-exploitation framework
ImpacketPython toolkit with AD/LDAP utilities
PowerViewPowerShell-based AD enumeration