389, 636, 3268, 3269 - LDAP
Default ports: 389 and 636(ldaps). Global Catalog (LDAP in ActiveDirectory) is available by default on ports 3268, and 3269 for LDAPS.
PORT STATE SERVICE REASON
389/tcp open ldap syn-ack
636/tcp open tcpwrappedGet public information (like the domain name):
nmap -n -sV --script "ldap* and not brute" <IP> #Using anonymous credentialsLdapsearch
Check null credentials or if your credentials are valid:
ldapsearch -x -H ldap://<IP> -D '' -w '' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
ldapsearch -h <IP> -bx "DC=<SUBDOMAIN>,DC=<TLD>"
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"# CREDENTIALS NOT VALID RESPONSE
search: 2
result: 1 Operations error
text: 000004DC: LdapErr: DSID-0C090A4C, comment: In order to perform this opera
tion a successful bind must be completed on the connection., data 0, v3839If you find something saying that the "bind must be completed" means that the credentials are incorrect.
You can extract everything from a domain using:
Extract users:
Extract computers:
Extract my info:
Extract Domain Admins:
Extract Domain Users:
Extract Enterprise Admins:
Extract Administrators:
Extract Remote Desktop Group:
To see if you have access to any password you can use grep after executing one of the queries:
Please, notice that the passwords that you can find here could not be the real ones...
LDAP enumeration with Python
You can try to enumerate a LDAP with or without credentials using python: pip3 install ldap3
First try to connect without credentials:
If the response is True like in the previous example, you can obtain some interesting data of the LDAP (like the naming context or domain name) server from:
Once you have the naming context you can make some more exciting queries. This simply query should show you all the objects in the directory:
Or dump the whole ldap:
Last updated
Was this helpful?