# T1136.002 - Domain Account
## [Description from ATT&CK](https://attack.mitre.org/techniques/T1136/002)
<blockquote>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 <code>net user /add /domain</code> 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.</blockquote>

## Atomic Tests

- [Atomic Test #1 - Create a new Windows domain admin user](#atomic-test-1---create-a-new-windows-domain-admin-user)

- [Atomic Test #2 - Create a new account similar to ANONYMOUS LOGON](#atomic-test-2---create-a-new-account-similar-to-anonymous-logon)

- [Atomic Test #3 - Create a new Domain Account using PowerShell](#atomic-test-3---create-a-new-domain-account-using-powershell)


<br/>

## Atomic Test #1 - Create a new Windows domain admin user
Creates a new domain admin user in a command prompt.

**Supported Platforms:** Windows


**auto_generated_guid:** fcec2963-9951-4173-9bfa-98d8b7834e62





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| username | Username of the user to create | String | T1136.002_Admin|
| password | Password of the user to create | String | T1136_pass123!|
| group | Domain administrator group to which add the user to | String | Domain Admins|


#### Attack Commands: Run with `command_prompt`! 


```cmd
net user "#{username}" "#{password}" /add /domain
net group "#{group}" "#{username}" /add /domain
```

#### Cleanup Commands:
```cmd
net user "#{username}" >nul 2>&1 /del /domain
```





<br/>
<br/>

## Atomic Test #2 - Create a new account similar to ANONYMOUS LOGON
Create a new account similar to ANONYMOUS LOGON in a command prompt.

**Supported Platforms:** Windows


**auto_generated_guid:** dc7726d2-8ccb-4cc6-af22-0d5afb53a548





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| username | Username of the user to create | String | ANONYMOUS  LOGON|
| password | Password of the user to create | String | T1136_pass123!|


#### Attack Commands: Run with `command_prompt`! 


```cmd
net user "#{username}" "#{password}" /add /domain
```

#### Cleanup Commands:
```cmd
net user "#{username}" >nul 2>&1 /del /domain
```





<br/>
<br/>

## Atomic Test #3 - Create a new Domain Account using PowerShell
Creates a new Domain User using the credentials of the Current User

**Supported Platforms:** Windows


**auto_generated_guid:** 5a3497a4-1568-4663-b12a-d4a5ed70c7d7





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| username | Name of the Account to be created | String | T1136.002_Admin|
| password | Password of the Account to be created | String | T1136_pass123!|


#### Attack Commands: Run with `powershell`! 


```powershell
$SamAccountName = '#{username}'
$AccountPassword = ConvertTo-SecureString '#{password}' -AsPlainText -Force
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$Context = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList ([System.DirectoryServices.AccountManagement.ContextType]::Domain)
$User = New-Object -TypeName System.DirectoryServices.AccountManagement.UserPrincipal -ArgumentList ($Context)
$User.SamAccountName = $SamAccountName
$TempCred = New-Object System.Management.Automation.PSCredential('a', $AccountPassword)
$User.SetPassword($TempCred.GetNetworkCredential().Password)
$User.Enabled = $True
$User.PasswordNotRequired = $False
$User.DisplayName = $SamAccountName
$User.Save()
$User
```

#### Cleanup Commands:
```powershell
cmd /c "net user #{username} /del >nul 2>&1"
```





<br/>
