> 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/ports-and-services/ldap-389-636-3268-3269/ldapsearch-attack.md).

# ldapsearch-Aufzählung

> Das **ldapsearch** Das Tool ermöglicht es Ihnen, einen LDAP-Server abzufragen, um Informationen über die Domänenstruktur, Benutzer, Gruppen und andere im Verzeichnis gespeicherte Objekte abzurufen. Es ist besonders nützlich für die Enumeration in einer Active-Directory-Umgebung.

### **Abruf der Naming Contexts**

Dieser Befehl ermittelt die **Naming Contexts** (LDAP-Wurzeln), die die Einstiegspunkte zum Erkunden der Domänenstruktur sind:

```bash
ldapsearch -x -H ldap://<SERVER_IP> -s base namingcontexts
```

```bash
ldapsearch -x -H ldap://10.10.10.175 -s base namingcontexts
```

* `-x`: Verwendet einfache (anonyme) Authentifizierung.
* `-H ldap://10.10.10.175`: Gibt das LDAP-Protokoll und die IP-Adresse des Zielservers an.
* `-s base`: Beschränkt die Suche auf die Wurzel der Domäne.
* `namingcontexts`: Angefordertes Attribut zur Anzeige der verfügbaren Wurzeln.

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

### **Analyse der Domänenstruktur**

Dieser Befehl untersucht die LDAP-Struktur, um Benutzer, Gruppen oder andere Objekte zu identifizieren:

```bash
ldapsearch -x -H ldap://<SERVER_IP> -b '<BASE_DN>'
```

```bash
ldapsearch -x -H ldap://10.10.10.175 -b 'DC=EGOTISTICAL-BANK,DC=LOCAL
```

* `-b 'DC=EGOTISTICAL-BANK,DC=LOCAL'`: Definiert die Suchbasis (den LDAP-Einstiegspunkt).
* Dieser Befehl gibt alle mit den aktuellen Rechten zugänglichen Informationen zurück.

### **Filtern nach Benutzern**

Um nur Domänenbenutzer zu extrahieren, wenden Sie eine zusätzliche Filterung mit `grep` und `sed`:

```bash
ldapsearch -x -H ldap://<SERVER_IP> -b '<BASE_DN>' "(objectClass=user)" | grep "dn: CN=" | sed 's/dn: CN=//;s/,.*//'
```

```bash
ldapsearch -x -H ldap://10.10.10.175 -b 'DC=EGOTISTICAL-BANK,DC=LOCAL' | grep "dn: CN=" | sed 's/dn: CN=//;s/,DC=EGOTISTICAL-BANK,DC=LOCAL//'
```

* `grep "dn: CN="`: Filtert Zeilen, die Common Names (CN) von Benutzern enthalten.
* `sed`: Bereinigt die Ergebnisse, um nur Benutzernamen anzuzeigen.

<div data-full-width="true"><figure><img src="/files/b6a8d5aed06a31e1656d838c4852cc803e09c55f" alt=""><figcaption></figcaption></figure></div>

### **LDAP-Suche mit Authentifizierung**

Dieser Befehl verwendet ein Konto zur Authentifizierung und Abfrage des LDAP-Servers:

```bash
ldapsearch -x -H ldap://<SERVER_IP> -D '<DOMAIN>/<USER>' -w '<PASSWORD>' -b '<BASE_DN>'
```

```bash
ldapsearch -x -H ldap://10.10.11.174 -D 'support.htb/ldap' -w 'nvEfEK16^1aM4$e7AclUf8x$tRWxPWO1%lmz' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
```

* `-D 'support.htb/ldap'`: Gibt das Benutzerkonto für die Authentifizierung an.
* `-w 'password'`: Passwort des verwendeten Kontos.
* Dieser Befehl gibt alle mit diesem Konto zugänglichen Daten zurück.

### **Suche nach spezifischen Informationen (erweiterte Filterung)**

Um nach spezifischen Informationen zu suchen, etwa einem in einem Feld gespeicherten Passwort, wenden Sie einen zusätzlichen Filter an:

```bash
ldapsearch -x -H ldap://<SERVER_IP> -D '<USER>@<DOMAIN>' -w '<PASSWORD>' -b '<BASE_DN>' | grep -i "<ATTRIBUTE>" -B <LINES_BEFORE>
```

```bash
ldapsearch -x -H ldap://10.10.11.174 -D 'ldap@support.htb' -w 'nvEfEK16^1aM4$e7AclUf8x$tRWxPWO1%lmz' -b "DC=support,DC=htb" | grep -i "info:" -B 20
```

* `grep -i "info:"`: Filtert Zeilen, die das `info` Attribut enthalten, z. B. eine Notiz oder ein Passwort.
* `-B 20`: Zeigt 20 Zeilen vor jedem Ergebnis an, um den Kontext herzustellen.

<figure><img src="/files/efeb2849184732efd528b996aa5c711e70a91f0a" 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/ports-and-services/ldap-389-636-3268-3269/ldapsearch-attack.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.
