LDAP
Pentesting LDAP - TCP Ports 389,3268,636,3269
Theory
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 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)
It run on port TCP 389 and 636(ldaps). The Global Catalog (LDAP in ActiveDirectory) is available by default on ports 3268, and 3269 for LDAPS.
Practice
A lot of information on an AD domain can be obtained through LDAP. Most of the information can only be obtained with an authenticated bind but metadata (naming contexts, DNS server name, Domain Functional Level (DFL)) can be obtainable anonymously, even with anonymous binding disabled.
UNIX-Like
The ldapsearch command is a shell-accessible interface to the ldap_search_ext(3) library call. It can be used to enumerate essential informations.
Anonymous Enumeration:
Enumerate the base domain.
Dump all readable ldap information as anonymous.
Dump ldap information as anonymous and filter.
Authenticated Enumeration:
Dump readable ldap informations with NTLM based authentication
Dump all readable ldap informations with Kerberos based authentication
Windows
Using PowerShell and .NET classes, we can enumerate the domain using LDAP. This can be very handy if we have compromised a computer in the domain with no administrative access and no RSAT module installed.
To acheive this, we can use the following function.
Then, we can use it as in following examples, by specifing our filter.
Last updated
Was this helpful?