# Password in description

## Configuring

1. Login to `DC02` as `Administrator` with the password `Welcome01!`.
2. Open the "Active Directory Users and Computers" administration tool on `DC02`.

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FWa5JY6qrnwlquga8DlCi%2Fimage.png?alt=media\&token=21807d67-38ef-4f07-a0d1-0c26b402d820)

3\. Open the "Emplyees" OU and right click on it, select "New" and then "User". Name the user `helpdesk` and set the password `SuperSecretField1!`. Make sure to deselect "User must change password at next logon" and select "Password never expires".

4\. Right click the user helpdesk and select "Properties". In the "General" tab fill in the password SuperSecretField1! in the description field. Then click on "Apply" and "OK".

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2Fzx9EKmmMeSVcrL1zlMXx%2Fimage.png?alt=media&#x26;token=27ed6078-8e85-4c08-ada2-763942e74490" alt=""></div>

## Attacking

### How it works

Every domain user is able to retrieve the non-protected attributes of all objects. One of these attributes is the description field. IT people used to save passwords in these fields, because its easy for them to see it in the Active Directory Users and Computers tool. But as I said, every user can see these attributes. So requesting all users with a description field, might give you access to other accounts.

### Tools

* [PowerView](https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1)

### Executing the attack

1. Login with the username `John` and password `Welcome2022!` on WS01.
2. Start PowerShell and download and execute an amsi and PowerView in memory:

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2Ft61jA6nABsbCP4b8okNe%2Fimage.png?alt=media&#x26;token=e9c412b3-16cc-464d-b33f-5416e11df6b3" alt=""></div>

3\. The following command request all domain users with a value in the description attribute and then only selects the samaccountname and description attributes:

```
Get-DomainUser | Where-Object -Property description | Select-Object samaccountname, description
```

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F0grlXDk4rXlcT58xoOiT%2Fimage.png?alt=media&#x26;token=16f22e9a-43e4-48c5-82ea-a9a00c211e36" alt=""></div>

The description from helpdesk looks like a password.

4\. Run PowerShell as another user (Shift rightlick) and fill in the username `helpdesk` and password `SuperSecretField1!`.

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FJWB2K40iYsoCz76lpLOr%2Fimage.png?alt=media\&token=d8ff8dad-e425-4023-a099-2f800169fa89)

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FbM4LtfOZar07wRB0miH4%2Fimage.png?alt=media&#x26;token=7984cbcc-98b3-44b0-afe1-c50c8d608565" alt=""></div>

If a PowerShell session opens it worked:

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FbWgMEb6O37ViHr31FUxf%2Fimage.png?alt=media&#x26;token=903325dc-25ab-4c36-b707-fc60cbd80a86" alt=""></div>

{% hint style="info" %}
It might be interesting to also check the descriptions of groups and computers. Never found password but sometimes some usefull information about the groups and systems!
{% endhint %}

## Defending

### Recommendations

* Periodically check for passwords in the description attribute and remove any passwords found.

Check for users with the attribute:

```
Get-ADUser -Filter {description -like '*'} -Properties samaccountname, description | Select-Object samaccountname, description
```

Remove the attribute:

```
Set-ADUser <USER> -Description $null
```

### Detection

## References

{% embed url="<https://hackdefense.com/publications/wachtwoorden-in-het-omschrijvingen-veld/>" %}

{% embed url="<https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1>" %}
