Basic Introduction
LDAP (Lightweight Directory Access Protocol) is a software protocol for enabling anyone to locate organizations, individuals, and other resources such as files and devices in a network, whether on the public Internet or on a corporate intranet. LDAP is a “lightweight” (smaller amount of code) version of Directory Access Protocol (DAP).
An LDAP directory can be distributed among many servers. Each server can have a replicated version of the total directory that is synchronized periodically. An LDAP server is called a Directory System Agent (DSA). An LDAP server that receives a request from a user takes responsibility for the request, passing it to other DSAs as necessary, but ensuring a single coordinated response for the user.
An LDAP directory is organized in a simple “tree” hierarchy consisting of the following levels:
- The root directory (the starting place or the source of the tree), which branches out to
- Countries, each of which branches out to
- Organizations, which branch out to
- Organizational units (divisions, departments, and so forth), which branches out to (includes an entry for)
- Individuals (which includes people, files, and shared resources such as printers)
Default port: 389 and 636(ldaps). Global Catalog (LDAP in ActiveDirectory) is available by default on ports 3268, and 3269 for LDAPS.
1 | PORT STATE SERVICE REASON |
Anonymous Access
Bypass TLS SNI check
1 | ldapsearch -H ldaps://company.com:636/ -x -s base -b '' "(objectClass=*)" "*" + |
Enumeration
Nmap
1 | nmap -n -sV --script "ldap* and not brute" <IP> |
Python LDAP3
1 | # pip3 install ldap3 |
ldapsearch
basic query:
1 | ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_SUBDOMAIN>,DC=<TLD>" |
null credentials
1 | ldapsearch -x -H ldap://<IP> -D '' -w '' -b "DC=<1_SUBDOMAIN>,DC=<TLD>" |
specific queries
1 | # Extract users |
GUIs
Apache Directory
https://directory.apache.org/studio/download/download-linux.html