> For the complete documentation index, see [llms.txt](https://g4b0.gitbook.io/g4b0-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://g4b0.gitbook.io/g4b0-docs/documentation/cheatsheets/quickstart/ldap.md).

# LDAP

```bash
ldapsearch -x -H ldap://10.129.95.180 -s base namingContexts
```

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

```bash
ldapdomaindump -u 'domain.htb\user' -p 'password' 'ip-target'
```

```bash
ldapsearch -h 172.16.5.5 -x -b "DC=INLANEFREIGHT,DC=LOCAL" -s sub "*" | grep -m 1 -B 10 pwdHistoryLength
```

### Enumeración de usuarios

```bash
ldapsearch -h 172.16.5.5 -x -b "DC=INLANEFREIGHT,DC=LOCAL" -s sub "(&(objectclass=user))"  | grep sAMAccountName: | cut -f2 -d" "
```

```bash
/windapsearch.py --dc-ip 172.16.5.5 -u "" -U
```

### Enumeracion general

```bash
python windapsearch.py -u "" --dc-ip 10.10.10.172
```

```bash
python windapsearch.py -u "" --dc-ip 10.10.10.172 -U --admin-objects
```

```bash
python windapsearch.py -u "" --dc-ip 10.10.10.172 -U -m "Remote Management Users"
```

```bash
python windapsearch.py -u "" --dc-ip 10.10.10.172 -U | grep '@' | cut -d ' ' -f 2 | cut -d '@' -f 1 | uniq > users.txt
```

#### Posibles passwords likeadas

```bash
windapsearch.py -d cascade.local --dc-ip 10.10.10.182 --full -U | grep -ie "pwd\|password"
```

#### DNSPY (Entorno windows)

```bash
Get-ADObject -ldapfilter "(&(ObjectClass=user)(isDeleted=TRUE))" -IncludeDeletedObjects
```

```bash
Get-ADObject -ldapfilter "(&(ObjectClass=user)(DisplayName=TempAdmin)(isDeleted=TRUE))" -IncludeDeletedObjects -Properties *
```

### BloodyAD

Obtener ZIP para analizar en bloodhound

```bash
bloodyad -u 'alex.turner' -p 'Checkpoint2024!' -d checkpoint.htb --host 10.129.16.243 get bloodhound
```

Enumeracion de ususarios del dominio con permisos de escritura

```bash
bloodyad --host dc01.checkpoint.htb -d checkpoint.htb -u alex.turner -p Checkpoint2024! get writa
```

Enumeracion del atributo nTSecurityDescriptor para encontrar el objeto Reanimate-Tombstones, con el objetivo de reactivar un usuario eliminado

```bash
bloodyAD --host 10.129.16.243 -d checkpoint.htb -u alex.turner -p 'Checkpoint2024!' get object "DC=checkpoint,DC=htb" --attr nTSecurityDescriptor --resolve-sd | grep -iA2 reanimate
```

### Analisis de Trust Bidireccional entre 2 Forest

#### Listar trusts del dominio

Muestra los dominios con los que existe relación de confianza y sus flags (`trustAttributes`)

```bash
bloodyad -u 'user' -p 'pass' -d dominio.htb --host  get trusts
```

#### Obtener dirección y atributos del trust (TDO)

Lee el Trusted Domain Object directamente para confirmar la dirección (`trustDirection`) y el tipo, esto confirma si el trust es bidireccional para evaluar abuso cross-forest

```bash
bloodyad -u 'user' -p 'pass' -d dominio.htb --host  \
  get object 'CN=dominio.ext,CN=System,DC=dominio,DC=htb' \
  --attr trustDirection,trustAttributes,trustType
```


---

# 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://g4b0.gitbook.io/g4b0-docs/documentation/cheatsheets/quickstart/ldap.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.
