{"id":2716,"date":"2016-03-14T20:28:03","date_gmt":"2016-03-15T00:28:03","guid":{"rendered":"https:\/\/adsecurity.org\/?p=2716"},"modified":"2016-10-19T09:53:11","modified_gmt":"2016-10-19T13:53:11","slug":"sneaky-active-directory-persistence-17-group-policy","status":"publish","type":"post","link":"https:\/\/adsecurity.org\/?p=2716","title":{"rendered":"Sneaky Active Directory Persistence #17: Group Policy"},"content":{"rendered":"<p>The content in this post describes a method through which an attacker could persist administrative access to Active Directory after having Domain Admin level rights for about 5 minutes.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/?p=1929\">Complete list of Sneaky Active Directory Persistence Tricks posts <\/a><\/p>\n<p>This post explores how an attacker could leverage the built-in Active Directory management capability called Group Policy and how to mitigate potential security issues.<\/p>\n<p><!--more--><\/p>\n<h4><strong>Group Policy Overview<\/strong><\/h4>\n<p>One of the key benefits to Active Directory is its management capability and core to this capability is Group Policy. Group Policy has several parts to it and can be challenging to manage in a large enterprise without third-party tools.<\/p>\n<p>Group Policy enables administrators to manage computers and users in Active Directory.\u00a0 Group Policies are saved as Group Policy Objects (GPOs) which are then associated with Active Directory objects such as sites, domains, or organizational units (OUs). Group Policies can include security options, registry keys, software installation, and scripts for startup and shutdown and domain members refresh group policy settings every 90 minutes by default (5 minutes for Domain Controllers). This means that Group Policy enforces configured settings on the targeted computer.<\/p>\n<p>In most Active Directory implementations, there is at least one GPO configured on the domain defining mandated password, Kerberos, and domain-wide policies; at least one GPO configured for the Domain Controllers OU; and at least one GPO configured for a servers\u00a0 and workstations OU. These GPOs define security settings specific to the environment and often configure administrative groups, include startup\/shutdown scripts, etc.. GPOs can be configured to set organization-defined security requirements at each level, and can be used for installing software and setting file and registry permissions. GPOs only apply to users and computers and can be filtered with groups or more specifically targeted using the Preferences component.\u00a0 The \u201cNo Override\u201d option ensures that the settings in a Group Policy are applied even if a GPO closer to the resource has contradicting settings.<\/p>\n<p>There are two Group Policy components:<\/p>\n<p>1. The &#8220;<a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc759367%28v=ws.10%29.aspx\">Group Policy Container<\/a>&#8221; is stored in Active Directory (&lt;DOMAIN&gt;, System, Policies)<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-ADUC-GroupPolicyObject-Attributes.jpg\" rel=\"attachment wp-att-2736\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2736\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-ADUC-GroupPolicyObject-Attributes.jpg\" alt=\"GPO-ADUC-GroupPolicyObject-Attributes\" width=\"489\" height=\"707\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-ADUC-GroupPolicyObject-Attributes.jpg 612w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-ADUC-GroupPolicyObject-Attributes-207x300.jpg 207w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/a><\/p>\n<p>2. The files that actually contain the policy settings (collectively referred to as the &#8220;<a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc759367%28v=ws.10%29.aspx\">Group Policy Template<\/a>&#8220;) are stored in SYSVOL.<br \/>\nAll domain Group Policies are stored in the following domain share: \\\\&lt;DOMAIN&gt;\\SYSVOL\\&lt;DOMAIN&gt;\\Policies\\<br \/>\n<a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policies.jpg\" rel=\"attachment wp-att-2737\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2737\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policies.jpg\" alt=\"GPO-SYSVOL-Policies\" width=\"457\" height=\"324\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policies.jpg 409w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policies-300x213.jpg 300w\" sizes=\"auto, (max-width: 457px) 100vw, 457px\" \/><\/a><\/p>\n<p>Each Group Policy Object in Active Directory has the following attributes (on the policy object in AD):<\/p>\n<ul>\n<li>displayName: This is the name given to the GPO by the creator.<\/li>\n<li>gPCFileSysPath: This points to the location in SYSVOL where the associated GPO files (aka &#8220;Group Policy Template&#8221;) are located.<\/li>\n<li>gPCMachineExtensionNames: This attribute lists the GPO client side extensions (CSEs) required to by the client process the machine specific Group Policy settings.<\/li>\n<li>gPCUserExtensionNames: This attribute lists the GPO client side extensions (CSEs) required to by the client process the user specific Group Policy settings.<\/li>\n<\/ul>\n<p>Using the <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ee617195.aspx\">PowerShell Active Directory module<\/a> cmdlet &#8220;<a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ee617198.aspx\">Get-ADObject<\/a>&#8220;, we can retrieve key GPO specific attributes for the GPO.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Policy-Object-Attributes-PowerShell-GetADObject.jpg\" rel=\"attachment wp-att-2735\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2735\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Policy-Object-Attributes-PowerShell-GetADObject.jpg\" alt=\"GPO-Policy-Object-Attributes-PowerShell-GetADObject\" width=\"1067\" height=\"220\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Policy-Object-Attributes-PowerShell-GetADObject.jpg 1067w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Policy-Object-Attributes-PowerShell-GetADObject-300x62.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Policy-Object-Attributes-PowerShell-GetADObject-768x158.jpg 768w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Policy-Object-Attributes-PowerShell-GetADObject-1024x211.jpg 1024w\" sizes=\"auto, (max-width: 1067px) 100vw, 1067px\" \/><\/a><\/p>\n<p>The PowerShell Active Directory module can be easily installed on Windows Server 2008 R2 (and newer) by running the following command in an Administrator PowerShell console:<\/p>\n<blockquote><p><em>Import-module servermanager ; add-windowsfeature rsat-ad-PowerShell<\/em><\/p><\/blockquote>\n<p>Additionally, every Group Policy has a GPO GUID used to connect GPO components:<\/p>\n<ul>\n<li>The GPO policy files are stored in a GPO object with the GPO GUID as the name.<\/li>\n<li>The Group Policy Template files in SYSVOL are stored in a folder with the GPO GUID as the name.<\/li>\n<li>The GPO policy object Distinguished Name is added to the attribute &#8220;gPLink&#8221; on the Organizational Unit (OU) the GPO is linked to.<\/li>\n<\/ul>\n<p>When a new GPO is created, it can be created in AD and not linked (in which case, it does nothing), or linked to an OU, domain, or site. Upon creation, a new Group Policy Object is created in the Group Policy Container (&lt;DOMAIN&gt;, System, Policies) and the associated files are created in SYSVOL structure (based on GPO GUID name). When linking a Group Policy to an OU, for example, the OU&#8217;s &#8220;gPLink&#8221; attribute is updated with the GPO&#8217;s Distinguished Name. This provides a method for the computer to identify what group policies apply to itself as well as any that apply to logging on user(s).<\/p>\n<p>Using the <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ee617195.aspx\">PowerShell Active Directory module<\/a> cmdlet &#8220;<a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ee617236.aspx\">Get-ADOrganizationalUnit<\/a>&#8220;, we can retrieve the Group Policies linked to the &#8220;Servers&#8221; OU.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit.jpg\" rel=\"attachment wp-att-2738\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2738\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit.jpg\" alt=\"GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit\" width=\"1102\" height=\"320\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit.jpg 1102w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit-300x87.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit-768x223.jpg 768w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-OU-LinkedGPOs-PowerShell-GetADOrganizationalUnit-1024x297.jpg 1024w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc778037%28v=ws.10%29.aspx\">SYSVOL <\/a>is the domain-wide share in Active Directory to which all authenticated users have read access. SYSVOL contains logon scripts, group policy data, and other domain-wide data which needs to be available anywhere there is a Domain Controller. The SYSVOL share is automatically synchronized and shared among all Domain Controllers.<\/p>\n<p>Within this Policies folder are folders for each GPO with the folder name the same as that GPO&#8217;s GUID.<br \/>\nEach GPO folder in SYSVOL has the following:<\/p>\n<ul>\n<li>Machine &#8211; this folder contains the machine specific settings for the GPO.<\/li>\n<li>User &#8211; this folder contains the user specific settings for the GPO.<\/li>\n<li>GPT.INI &#8211; this file contains the configuration settings for the GPO.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policy-Folder-Contents.jpg\" rel=\"attachment wp-att-2739\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2739\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policy-Folder-Contents.jpg\" alt=\"GPO-SYSVOL-Policy-Folder-Contents\" width=\"507\" height=\"139\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policy-Folder-Contents.jpg 507w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-SYSVOL-Policy-Folder-Contents-300x82.jpg 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/a><\/p>\n<p>Note that the GPO is tracked in AD via the GPO GUID which has a separate AD object GUID for the AD object. There are a few different reasons for this, and one of the key reasons is to ensure there are predictable GUIDs for specific Group Policy Objects regardless of the Active Directory instance. The &#8220;Default Domain Policy&#8221; GPO&#8217;s GUID is &#8220;31B2F340-016D-11D2-945F-00C04FB984F9&#8221; and the &#8220;Default Domain Controller Policy &#8221; GPO&#8217;s GUID is &#8220;6AC1786C-016F-11D2-945F-00C04FB984F9&#8221; by default.<\/p>\n<p>In this graphic the ObjectGUID attribute is &#8220;0115c3fa-1628-40d0-8a68-2d05530d6f76&#8221; which is obviously not the same as the GPO GUID &#8220;31B2F340-016D-11D2-945F-00C04FB984F9&#8221;.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-DefaultDomainPolicy-GetADObject-02.jpg\" rel=\"attachment wp-att-2776\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2776\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-DefaultDomainPolicy-GetADObject-02.jpg\" alt=\"GPO-DefaultDomainPolicy-GetADObject-02\" width=\"698\" height=\"443\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-DefaultDomainPolicy-GetADObject-02.jpg 1111w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-DefaultDomainPolicy-GetADObject-02-300x190.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-DefaultDomainPolicy-GetADObject-02-768x487.jpg 768w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-DefaultDomainPolicy-GetADObject-02-1024x650.jpg 1024w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Group Policy Management<\/strong><\/h4>\n<p>Group Policy management is often delegated in large enterprises so several different organizations are able to create, modify, and delete Group Policies. This issue with this is that Group Policy quickly gets unruly and difficult to manage since many more than the originally designed (and selected) admins have GPO admin rights. These rights are often delegated at the domain level, so edit (or full) rights apply to all domain GPOs, even those that apply to the Domain (everything) and\/or Domain Controllers.<\/p>\n<p>The Group Policy Management Console (GPMC) is the primary tool for Group Policy administration and there&#8217;s a PowerShell module (GroupPolicy) which is extremely useful for reporting on and backing up GPOs (please backup the domain GPOs regularly) using <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ee461052.aspx\">Backup-GPO<\/a>.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GroupPolicyManagementConsole.jpg\" rel=\"attachment wp-att-2732\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2732\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GroupPolicyManagementConsole.jpg\" alt=\"GroupPolicyManagementConsole\" width=\"617\" height=\"351\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GroupPolicyManagementConsole.jpg 1006w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GroupPolicyManagementConsole-300x170.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GroupPolicyManagementConsole-768x436.jpg 768w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/PowerShell-GroupPolicy-Module-Cmdlets.jpg\" rel=\"attachment wp-att-2734\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2734\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/PowerShell-GroupPolicy-Module-Cmdlets.jpg\" alt=\"PowerShell-GroupPolicy-Module-Cmdlets\" width=\"519\" height=\"483\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/PowerShell-GroupPolicy-Module-Cmdlets.jpg 1017w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/PowerShell-GroupPolicy-Module-Cmdlets-300x279.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/PowerShell-GroupPolicy-Module-Cmdlets-768x715.jpg 768w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/a><\/p>\n<h4><strong>Group Policy Persistence Capability<\/strong><\/h4>\n<p>Group Policy was designed to provide simplified management of resources in a domain, though its capability can also be co-opted by an attacker to push out malware, create\/modify scheduled tasks, <a href=\"https:\/\/adsecurity.org\/?p=559\">downgrade credential protections<\/a>, add a new local account to all computers that are added to the local Administrators group. and even <a href=\"https:\/\/adsecurity.org\/?p=2053\">change existing security policies enabling clear-text password extraction<\/a>.<\/p>\n<p>Some possibilities:<\/p>\n<ul>\n<li>Configure a PowerShell or VBS script to set group membership at the domain or server level<\/li>\n<li>Perform one of the other <a href=\"https:\/\/adsecurity.org\/?p=1929\">&#8220;Sneaky Persistence Tricks&#8221; I outlined previously<\/a>.<\/li>\n<li>Running <a href=\"https:\/\/adsecurity.org\/?p=2207\">Invoke-Mimikatz<\/a> on all Domain Controllers as SYSTEM every week.<\/li>\n<li>Pull the KRBTGT account and then schedule a task that runs DCSync on certain computers throughout the forest using forged Kerberos tickets.<\/li>\n<li>Install &amp; Re-install malware on every computer in the Domain\/Forest.<\/li>\n<li>Dump all <a href=\"https:\/\/adsecurity.org\/?p=1790\">Microsoft LAPS<\/a> passwords for all computer local Administrator accounts by running a PowerShell script automatically on one or all Domain Controllers. There are plenty of options for an attacker once Group Policy is part of their toolkit.<\/li>\n<\/ul>\n<p>In fact, the <a href=\"https:\/\/www2.fireeye.com\/rs\/848-DID-242\/images\/Mtrends2016.pdf\">Mandiant M-Trends 2016 report <\/a>covering activity in 2015 includes information about how attackers are leveraging Group Policy to deploy malware:<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/Mandiant-MTrends2016-GPO-Persistence.jpg\" rel=\"attachment wp-att-2768\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2768\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/Mandiant-MTrends2016-GPO-Persistence.jpg\" alt=\"Mandiant-MTrends2016-GPO-Persistence\" width=\"580\" height=\"236\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/Mandiant-MTrends2016-GPO-Persistence.jpg 1127w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/Mandiant-MTrends2016-GPO-Persistence-300x122.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/Mandiant-MTrends2016-GPO-Persistence-768x313.jpg 768w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/Mandiant-MTrends2016-GPO-Persistence-1024x417.jpg 1024w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p><strong>Note that the person who hacked Haking Team leveraged Group Policy as part of the hack: <a href=\"http:\/\/pastebin.com\/raw\/0SNSvyjJ\">http:\/\/pastebin.com\/raw\/0SNSvyjJ<\/a><\/strong><span style=\"text-decoration: underline;\"><br \/>\n<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><br \/>\nRed Team Note on Group Policy:<\/span><br \/>\nThe default Group Policy application behavior is to &#8220;refresh the group policy&#8221; on the client, though this doesn&#8217;t actually mean the GPO settings are re-applied. By default, the GPO&#8217;s settings are only reapplied if the GPO was modified prior to the refresh. This means that one could reverse a GPO enforced setting via the computer&#8217;s registry (typically with admin rights) and the unauthorized setting remains until the GPO is modified, after which the GPO settings are re-applied.<\/p>\n<p><span style=\"text-decoration: underline;\">Blue Team Defenses:<\/span><br \/>\nAfter testing, change the Group Policy default setting to re-apply GPO settings at every refresh (Process even if the Group Policy objects have not changed). This does have a potential performance hit on the client, but will ensure all GPO enforced settings are re-applied.<\/p>\n<p><em>Computer Configuration, Policies, Administrative Templates, System, Group Policy, Configure security policy processing<\/em>: Set to Enabled.<br \/>\nAlso check the box for &#8220;<em>Process even if the Group Policy objects have not changed<\/em>&#8221;<\/p>\n<p>It&#8217;s also recommended to configure the same settings for each of the following:<\/p>\n<ul>\n<li><em>Computer Configuration, Policies, Administrative Templates, System, Group Policy, Configure registry policy processing<\/em><\/li>\n<li><em>Computer Configuration, Policies, Administrative Templates, System, Group Policy, Configure scripts policy processing<\/em><\/li>\n<li>As well as any other policy settings as needed.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Enforce.jpg\" rel=\"attachment wp-att-2728\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2728\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Enforce.jpg\" alt=\"GPO-Enforce\" width=\"618\" height=\"716\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Enforce.jpg 760w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Enforce-259x300.jpg 259w\" sizes=\"auto, (max-width: 618px) 100vw, 618px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Group Policy Exploit Capability<\/strong><\/h4>\n<p>Though this post focuses on retaining domain-level privileged access (&#8220;Domain Admin&#8221; rights), there are several ways in which an existing organization&#8217;s Group Policy configuration could be used to escalate access. The obvious method is to <a href=\"https:\/\/adsecurity.org\/?p=2288\">exploit existing Group Policy Preference credentials<\/a> in the environment which enables an attacker to escalate access from domain user to server\/application\/OU admin, or even Domain Admin. The less obvious method involves finding GPOs linked at either the domain or a top level OU with custom security settings.<\/p>\n<p>Based on <a href=\"http:\/\/www.TrimarcSecurity.com\">AD security assessments I have performed<\/a>, I&#8217;ve found that organizations frequently have GPOs linked at a high level with custom security settings providing edit rights to accounts that are not Active Directory Administrators. This provides an avenue for privilege escalation since the GPO can be reconfigured to run a script or change security.<\/p>\n<p><a href=\"https:\/\/github.com\/PowerShellMafia\/PowerSploit\/blob\/master\/Recon\/PowerView.ps1\">PowerView<\/a>, now integrated into <a href=\"https:\/\/github.com\/PowerShellMafia\/PowerSploit\">PowerSploit<\/a>, includes some interesting Group Policy enumeration capability via PowerShell.<\/p>\n<p>The following example shows a Group Policy called &#8220;Full Auditing Policy&#8221; linked at the Domain level which has &#8220;Edit settings&#8221; rights delegated to the &#8220;Han Solo&#8221; (Server Admin) account.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Security-Delegation-NonDA.jpg\" rel=\"attachment wp-att-2741\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2741\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Security-Delegation-NonDA.jpg\" alt=\"GPO-Domain-GroupPolicy-Security-Delegation-NonDA\" width=\"610\" height=\"504\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Security-Delegation-NonDA.jpg 688w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Security-Delegation-NonDA-300x248.jpg 300w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Han Solo is a member of the &#8220;Server Admins&#8221; group which is not a domain admin group.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-HanSolo-GetADUser-Prop-MemberOf.jpg\" rel=\"attachment wp-att-2743\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2743\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-HanSolo-GetADUser-Prop-MemberOf.jpg\" alt=\"GPO-HanSolo-GetADUser-Prop-MemberOf\" width=\"588\" height=\"372\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-HanSolo-GetADUser-Prop-MemberOf.jpg 875w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-HanSolo-GetADUser-Prop-MemberOf-300x190.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-HanSolo-GetADUser-Prop-MemberOf-768x486.jpg 768w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/a><\/p>\n<p>Since Han Solo has the rights to edit this domain linked GPO, let&#8217;s modify it.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Exploit-ScheduledTask.jpg\" rel=\"attachment wp-att-2769\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2769\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Exploit-ScheduledTask.jpg\" alt=\"GPO-Domain-GroupPolicy-Exploit-ScheduledTask\" width=\"575\" height=\"442\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Exploit-ScheduledTask.jpg 1012w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Exploit-ScheduledTask-300x231.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-Domain-GroupPolicy-Exploit-ScheduledTask-768x591.jpg 768w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/a><\/p>\n<p>After editing the Group Policy, this GPO will now add a scheduled task on every computer in the domain, enabling any type of activity the attacker wishes.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>&#8220;Hidden Group Policy&#8221; &#8211; Group Policies Applied to Sites<br \/>\n<\/strong><\/h4>\n<p>We know that Group Policy is typically applied to Organizational Units and we can easily view them in GPMC.<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-01.jpg\" rel=\"attachment wp-att-2771\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2771\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-01.jpg\" alt=\"GPO-GPMC-01\" width=\"702\" height=\"410\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-01.jpg 954w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-01-300x175.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-01-768x448.jpg 768w\" sizes=\"auto, (max-width: 702px) 100vw, 702px\" \/><\/a><\/p>\n<p>However, many admins don&#8217;t realize that while it is not best practice to link Group Policies to sites, there&#8217;s nothing preventing a Domain Admin (Enterprise Admin) from doing so.<\/p>\n<p>All that&#8217;s needed is to select the AD sites that should be shown in the Group Policy Management Console and link the new\/updated Group Policies to the site(s)<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-ShowSites.jpg\" rel=\"attachment wp-att-2773\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2773\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-ShowSites.jpg\" alt=\"GPO-GPMC-ShowSites\" width=\"300\" height=\"284\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-ShowSites.jpg 402w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-ShowSites-300x284.jpg 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Looking at GPMC, we can see there are two Group Policies linked to the HQ Site and both of them were last modified recently (hint, hint).<\/p>\n<p><a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-New-GPOs-Linked-To-Site-02.jpg\" rel=\"attachment wp-att-2774\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2774\" src=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-New-GPOs-Linked-To-Site-02.jpg\" alt=\"GPO-GPMC-New-GPOs-Linked-To-Site-02\" width=\"605\" height=\"447\" srcset=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-New-GPOs-Linked-To-Site-02.jpg 952w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-New-GPOs-Linked-To-Site-02-300x222.jpg 300w, https:\/\/adsecurity.org\/wp-content\/uploads\/2016\/03\/GPO-GPMC-New-GPOs-Linked-To-Site-02-768x567.jpg 768w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/a><\/p>\n<h5><em>Would your current monitoring system notify on this change?<\/em><\/h5>\n<p>&nbsp;<\/p>\n<h4><strong>Mitigation<\/strong><\/h4>\n<p>All Group Policies in the AD environment should be configured for a single purpose and monitored for unauthorized modification, especially GPOs linked to the domain, Domain Controllers OU, and\/or a top level OU such as workstations, servers, admins, etc.<\/p>\n<p>Delegated permissions to Group Policy should be reviewed on a regular basis, especially those linked to top-level OUs. Only Active Directory administrators should have modify rights to GPOs applied to the domain, top-level OUs, and any GPOs linked to critical assets (Domain Controllers, servers, admin computers, etc).<\/p>\n<p>Additionally, all sites should be reviewed for linked Group Policies since these GPOs can cross domain boundaries enabling privilege escalation across domains in the same AD forest.<\/p>\n<p>SYSVOL permissions are critical and must remain the same as the default settings since SYSYOL contains the actual Group Policy settings in files that are applied by GPO clients. If a GPO configuration file has permissions that enables some on who is not an Active Directory admin to change the file, and thus change what action the GPO client actually performs, an attacker could quickly escalate permissions up to Domain Admin level.<\/p>\n<h4><strong>Resources<\/strong><\/h4>\n<ul>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/musings_of_a_technical_tam\/2012\/02\/13\/group-policy-basics-part-1-understanding-the-structure-of-a-group-policy-object\/\">Group Policy Basics \u2013 Part 1: Understanding the Structure of a Group Policy Object<\/a><\/li>\n<li><a href=\"http:\/\/www.harmj0y.net\/blog\/redteaming\/local-group-enumeration\/\">Local Group Enumeration using PowerView (includes Group Policy features)<\/a><\/li>\n<li><a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc725745.aspx\">Configure a Scheduled Task<\/a><\/li>\n<li><a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/dn581922.aspx\">Group Policy Preferences<\/a><\/li>\n<li><a href=\"https:\/\/adsecurity.org\/?p=2288\">Exploit existing Group Policy Preference credentials<\/a><\/li>\n<li><a href=\"https:\/\/adsecurity.org\/?p=1929\">Complete list of Sneaky Active Directory Persistence Tricks posts <\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The content in this post describes a method through which an attacker could persist administrative access to Active Directory after having Domain Admin level rights for about 5 minutes. Complete list of Sneaky Active Directory Persistence Tricks posts This post explores how an attacker could leverage the built-in Active Directory management capability called Group Policy &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/adsecurity.org\/?p=2716\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[565,11,2],"tags":[20,1043,101,36,919,908,448,12,196,909,917,910,1044,1042,918,568,916,596,622,621],"class_list":["post-2716","post","type-post","status-publish","format-standard","hentry","category-activedirectorysecurity","category-microsoft-security","category-technical-reference","tag-activedirectory","tag-badgpo","tag-domaincontroller","tag-get-adobject","tag-get-adorganizationalunit","tag-gplink","tag-gpo","tag-gpp","tag-grouppolicy","tag-grouppolicyobject","tag-grouppolicypersistence","tag-grouppolicytemplate","tag-maliciousgpo","tag-maliciousgrouppolicy","tag-powershell-active-directory-module","tag-privilegeescalation","tag-sitegpos","tag-sneakyadpersistence","tag-sneakypersistence","tag-sysvol","item-wrap"],"_links":{"self":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/2716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2716"}],"version-history":[{"count":27,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/2716\/revisions"}],"predecessor-version":[{"id":3297,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/2716\/revisions\/3297"}],"wp:attachment":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}