Expand description
gpo-forge — offensive Group Policy Object write payloads.
§What SharpGPOAbuse-class attacks need
Once an attacker has Write on a GPO object (via a delegated OU
creator, gPLink write, or SDDL misconfiguration), they can turn that
into machine or user compromise by dropping one of a small set of
well-known files into SYSVOL:
-
AddLocalAdmin → append a SID to
[Group Membership]inMachine\Microsoft\Windows NT\SecEdit\GptTmpl.inf. Applies via the Security CSE on the nextgpupdate. Persistent because the CSE sets group membership — it doesn’t merge — so a scheduled reset from a legitimate admin gets clobbered every 90 minutes. -
NewImmediateTask → drop a
ScheduledTasks.xmlatMachine\Preferences\ScheduledTasks\ScheduledTasks.xml. The Scheduled Tasks CSE registers the task as SYSTEM at policy-refresh time and runs it exactly once (Immediate). Combined with an attacker-controlled command line this is a clean SYSTEM RCE on every machine the GPO applies to.
Both attacks need three extra pieces the CSE machinery relies on:
gpt.iniat the GPO root, with theVersion=field bumped so clients pick up the change.gPCFileSysPath— the LDAP path pointing at the SYSVOL directory (must exist and match the GUID; the caller already has this).gPCMachineExtensionNames(LDAP) updated so the CSE actually processes the newly-added file — Windows only runs a CSE if its GUID appears in the extension list.
§What this crate builds
add_local_admin_gpttmpl— the fullGptTmpl.infcontent that addstrustee_sidto BUILTIN\Administrators. Overwrites any existing file — the caller merges if merge semantics are needed.new_immediate_task_xml— theScheduledTasks.xmlcontent registering an Immediate task that runscommandas SYSTEM.gpt_ini— thegpt.inicontent withVersion=<n>.bump_gpo_version_number— the versionNumber math (upper 16 bits = user counter, lower 16 = computer counter).cse_list_add— merge a required CSE GUID into an existinggPCMachineExtensionNames/gPCUserExtensionNamesvalue.- CSE GUID constants (
CSE_GUID_*) for the two attacks above.
§What this crate does not do
- No SYSVOL SMB write. Use
smb2-clientor your existing SMB layer. - No LDAP write for
versionNumber/gPCMachineExtensionNames. Useadhammer-ldap/msldap-ext/ldap3. - No permission preflight — the caller is expected to verify write
ACL on the GPO (via
ad-acl) before invoking these builders.
Constants§
- CSE_
GUID_ SCHEDULED_ TASKS - Scheduled Tasks Preference CSE — consumes
ScheduledTasks.xml. - CSE_
GUID_ SECURITY - Security CSE — the client-side extension that consumes
GptTmpl.infand applies group-membership + security-options policy. - TOOLEXT_
GUID_ GPP - The generic Group Policy Preferences (client-side) tool extension GUID paired with every GPP CSE.
- TOOLEXT_
GUID_ SECURITY - The “Security” toolExtensionGuid that must appear on the User side of the extension name list for user policy. For our Machine-scoped attacks we don’t need this.
Functions§
- add_
local_ admin_ gpttmpl - Build the full
GptTmpl.infcontent that addstrustee_sidto BUILTIN\Administrators (*S-1-5-32-544) via the Security CSE’s[Group Membership]section. - bump_
gpo_ version_ number - Compute the new
versionNumbervalue for a GPO’s LDAP attribute. - cse_
list_ add - Merge
required_cse+required_toolextinto an existinggPCMachineExtensionNames(orgPCUserExtensionNames) value. - gpt_ini
- Build a
gpt.inifile withVersion=<n>.display_nameis written into the (informational)DisplayName=field the ADMX loader shows. - new_
immediate_ task_ xml - Build the
ScheduledTasks.xmlcontent that registers an Immediate task runningcommand(with optionalarguments) asNT AUTHORITY\SYSTEMexactly once at next policy refresh. - split_
gpo_ version_ number - Split a packed
versionNumberinto(user, computer)counters.