LDAP Injection
I'll try to be very concise, so you'll need to use that brain of yours to connect the dots.
I won't insult your intelligence by talking of the OR and the AND cases. If you understand how things work and you know your boolean algebra, then you'll be fine.
Also, I suggest that you read a brief tutorial about LDAP before proceeding.
Let's get started!
LDAP (Lightweight Directory Access Protocol) is a protocol for accessing directory servers. A directory server is a hierarchical object oriented database.
The database is organized like a tree where each node, called entry, is an object which contains mandatory and optional attributes.
To search the database, one can write filters that look like this:
Some important things to know:
Test for injectability
Just try to produce an error, for instance by entering ")".
Normal injection
Consider
Note that we have two filters concatenated:
Important: If the parser is still complaining, you might need to inject into both params in order to form a single filter. Let's say you can't use "*" as Pwd; what would you enter as Uname and Pwd to get just a single filter and bypass the login?
Boolean injection
Beware that many people call this Blind injection.
Like with SQLi, if we can get the server to answer Yes/No questions, we can extract any information a bit at a time.
Suppose the query is
We get
This means that if <QUESTION> if false, the filter doesn't find anything, whereas if <QUESTION> is true, the filter should find something.
This method works if the following questions give different results:
Challenges
I found two interesting challenges for you.
Go to root-me, register and look for the challenges of type "Web - Server". Try to complete the challenges "LDAP injection - authentication" and "LDAP injection - blind".
Let me know if you have any problems with this tutorial or the two challenges.
I'll try to be very concise, so you'll need to use that brain of yours to connect the dots.
I won't insult your intelligence by talking of the OR and the AND cases. If you understand how things work and you know your boolean algebra, then you'll be fine.
Also, I suggest that you read a brief tutorial about LDAP before proceeding.
Let's get started!
LDAP (Lightweight Directory Access Protocol) is a protocol for accessing directory servers. A directory server is a hierarchical object oriented database.
The database is organized like a tree where each node, called entry, is an object which contains mandatory and optional attributes.
To search the database, one can write filters that look like this:
- (&(objectClass=Book)(author=Stephen King))
Some important things to know:
Code
(&) is TRUE
(|) is FALSE
attr=* means "attr exists"
attr=ma* means "attr's value starts with "ma"
attr=*a* means "attr's value contains "a"
objectClass this attribute is always present and indicates the class of the object/entryTest for injectability
Just try to produce an error, for instance by entering ")".
Normal injection
Consider
- (&(USER=Uname)(PASSWORD=Pwd))
- Uname = john)(&)
- (&(USER=john)(&))(PASSWORD=Pwd))
Note that we have two filters concatenated:
- (&(USER=john)(&))
- (PASSWORD=Pwd)
- john)(&))((
- (&(USER=john)(&))(()(PASSWORD=Pwd))
Important: If the parser is still complaining, you might need to inject into both params in order to form a single filter. Let's say you can't use "*" as Pwd; what would you enter as Uname and Pwd to get just a single filter and bypass the login?
Boolean injection
Beware that many people call this Blind injection.
Like with SQLi, if we can get the server to answer Yes/No questions, we can extract any information a bit at a time.
Suppose the query is
- (|(objectClass=val)(name=John))
- void)<QUESTION>)((
We get
- (|(objectClass=void)<QUESTION>)(()(name=John))
This means that if <QUESTION> if false, the filter doesn't find anything, whereas if <QUESTION> is true, the filter should find something.
This method works if the following questions give different results:
- <QUESTION> = (&)
- <QUESTION> = (|)
- <QUESTION> = (height=*)
- <QUESTION> = (height<100)
- <QUESTION> = (user=John)(surname=A*)
- <QUESTION> = (user=John)(surname=*a*)
Challenges
I found two interesting challenges for you.
Go to root-me, register and look for the challenges of type "Web - Server". Try to complete the challenges "LDAP injection - authentication" and "LDAP injection - blind".
Let me know if you have any problems with this tutorial or the two challenges.

