Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Fix GPO collection collecting versioning GPO when GPA is used #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sharphound2/Enumeration/ContainerHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static void BuildGpoCache(string domain)
return;

domain = d.Name;
foreach (var entry in _utils.DoSearch("(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*))",
foreach (var entry in _utils.DoSearch("(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*)(flags=*))",
SearchScope.Subtree, new[] {"displayname", "name"}, domain))
{
var dName = entry.GetProp("displayname");
Expand Down
8 changes: 4 additions & 4 deletions Sharphound2/Enumeration/LdapFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static LdapData BuildLdapData(ResolvedCollectionMethod methods, bool ex

if ((methods & ResolvedCollectionMethod.ACL) != 0)
{
filterparts.Add("(|(samAccountType=805306368)(samAccountType=805306369)(samAccountType=268435456)(samAccountType=268435457)(samAccountType=536870912)(samAccountType=536870913)(objectClass=domain)(objectCategory=groupPolicyContainer))");
filterparts.Add("(|(samAccountType=805306368)(samAccountType=805306369)(samAccountType=268435456)(samAccountType=268435457)(samAccountType=536870912)(samAccountType=536870913)(objectClass=domain)(&(objectCategory=groupPolicyContainer)(flags=*)))");
props.AddRange(new[]
{
"samaccountname", "distinguishedname", "dnshostname", "samaccounttype", "ntsecuritydescriptor", "displayname", "objectclass", "objectsid", "name"
Expand All @@ -54,7 +54,7 @@ internal static LdapData BuildLdapData(ResolvedCollectionMethod methods, bool ex

if ((methods & ResolvedCollectionMethod.ObjectProps) != 0)
{
filterparts.Add("(|(samaccounttype=268435456)(samaccounttype=268435457)(samaccounttype=536870912)(samaccounttype=536870913)(samaccounttype=805306368)(samaccounttype=805306369)(objectclass=domain)(objectclass=organizationalUnit)(objectcategory=groupPolicyContainer))");
filterparts.Add("(|(samaccounttype=268435456)(samaccounttype=268435457)(samaccounttype=536870912)(samaccounttype=536870913)(samaccounttype=805306368)(samaccounttype=805306369)(objectclass=domain)(objectclass=organizationalUnit)(&(objectCategory=groupPolicyContainer)(flags=*)))");
props.AddRange(new[]
{
"samaccountname", "distinguishedname", "samaccounttype", "pwdlastset", "lastlogon", "lastlogontimestamp", "objectsid",
Expand All @@ -67,7 +67,7 @@ internal static LdapData BuildLdapData(ResolvedCollectionMethod methods, bool ex

if ((methods & ResolvedCollectionMethod.GPOLocalGroup) != 0)
{
filterparts.Add("(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*))");
filterparts.Add("(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*)(flags=*))");
props.AddRange(new[]
{
"displayname", "name", "gpcfilesyspath", "objectclass"
Expand All @@ -76,7 +76,7 @@ internal static LdapData BuildLdapData(ResolvedCollectionMethod methods, bool ex

if ((methods & ResolvedCollectionMethod.Container) != 0)
{
filterparts.Add("(|(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*))(objectcategory=organizationalUnit)(objectClass=domain))");
filterparts.Add("(|(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*)(flags=*))(objectcategory=organizationalUnit)(objectClass=domain))");
props.AddRange(new[]
{
"displayname", "name", "objectguid", "gplink", "gpoptions", "objectclass"
Expand Down