From 39eb15030fa3e678d1f939d88f14597bf017439a Mon Sep 17 00:00:00 2001 From: Jonas Knudsen Date: Wed, 25 Oct 2023 02:11:58 -0700 Subject: [PATCH] feat: configuration class collection --- src/CommonLib/Enums/Labels.cs | 1 + src/CommonLib/Extensions.cs | 3 +++ src/CommonLib/LDAPQueries/LDAPFilter.cs | 12 ++++++++++++ src/CommonLib/LDAPUtils.cs | 1 + src/CommonLib/Processors/ACLProcessor.cs | 1 + src/CommonLib/SearchResultEntryWrapper.cs | 1 + 6 files changed, 19 insertions(+) diff --git a/src/CommonLib/Enums/Labels.cs b/src/CommonLib/Enums/Labels.cs index c5611ff2..7f07f5ce 100644 --- a/src/CommonLib/Enums/Labels.cs +++ b/src/CommonLib/Enums/Labels.cs @@ -12,6 +12,7 @@ public enum Label Domain, OU, Container, + Configuration, CertTemplate, CertAuthority, RootCA, diff --git a/src/CommonLib/Extensions.cs b/src/CommonLib/Extensions.cs index 4c001e6e..cfae61bd 100644 --- a/src/CommonLib/Extensions.cs +++ b/src/CommonLib/Extensions.cs @@ -369,6 +369,8 @@ public static Label GetLabel(this SearchResultEntry entry) objectType = Label.Domain; else if (objectClasses.Contains(ContainerClass, StringComparer.InvariantCultureIgnoreCase)) objectType = Label.Container; + else if (objectClasses.Contains(ConfigurationClass, StringComparer.InvariantCultureIgnoreCase)) + objectType = Label.Configuration; else if (objectClasses.Contains(PKICertificateTemplateClass, StringComparer.InvariantCultureIgnoreCase)) objectType = Label.CertTemplate; else if (objectClasses.Contains(PKIEnrollmentServiceClass, StringComparer.InvariantCultureIgnoreCase)) @@ -395,6 +397,7 @@ public static Label GetLabel(this SearchResultEntry entry) private const string OrganizationalUnitClass = "organizationalUnit"; private const string DomainClass = "domain"; private const string ContainerClass = "container"; + private const string ConfigurationClass = "configuration"; private const string PKICertificateTemplateClass = "pKICertificateTemplate"; private const string PKIEnrollmentServiceClass = "pKIEnrollmentService"; private const string CertificationAutorityClass = "certificationAuthority"; diff --git a/src/CommonLib/LDAPQueries/LDAPFilter.cs b/src/CommonLib/LDAPQueries/LDAPFilter.cs index 2606a1c9..5474e9b4 100644 --- a/src/CommonLib/LDAPQueries/LDAPFilter.cs +++ b/src/CommonLib/LDAPQueries/LDAPFilter.cs @@ -142,6 +142,18 @@ public LDAPFilter AddContainers(params string[] conditions) return this; } + /// + /// Add a filter that will include Configuration objects + /// + /// + /// + public LDAPFilter AddConfiguration(params string[] conditions) + { + _filterParts.Add(BuildString("(objectClass=configuration)", conditions)); + + return this; + } + /// /// Add a filter that will include Computer objects /// diff --git a/src/CommonLib/LDAPUtils.cs b/src/CommonLib/LDAPUtils.cs index 2b539f86..bb757da8 100644 --- a/src/CommonLib/LDAPUtils.cs +++ b/src/CommonLib/LDAPUtils.cs @@ -159,6 +159,7 @@ public IEnumerable GetWellKnownPrincipalOutput(string domain) Label.Domain => new OutputTypes.Domain(), Label.OU => new OU(), Label.Container => new Container(), + Label.Configuration => new Container(), _ => throw new ArgumentOutOfRangeException() }; diff --git a/src/CommonLib/Processors/ACLProcessor.cs b/src/CommonLib/Processors/ACLProcessor.cs index cdc034bc..18e91138 100644 --- a/src/CommonLib/Processors/ACLProcessor.cs +++ b/src/CommonLib/Processors/ACLProcessor.cs @@ -31,6 +31,7 @@ static ACLProcessor() {Label.GPO, "f30e3bc2-9ff0-11d1-b603-0000f80367c1"}, {Label.OU, "bf967aa5-0de6-11d0-a285-00aa003049e2"}, {Label.Container, "bf967a8b-0de6-11d0-a285-00aa003049e2"}, + {Label.Configuration, "bf967a87-0de6-11d0-a285-00aa003049e2"}, {Label.RootCA, "3fdfee50-47f4-11d1-a9c3-0000f80367c1"}, {Label.AIACA, "3fdfee50-47f4-11d1-a9c3-0000f80367c1"}, {Label.EnterpriseCA, "ee4aa692-3bba-11d2-90cc-00c04fd91ab1"}, diff --git a/src/CommonLib/SearchResultEntryWrapper.cs b/src/CommonLib/SearchResultEntryWrapper.cs index d627fef4..0f0856e3 100644 --- a/src/CommonLib/SearchResultEntryWrapper.cs +++ b/src/CommonLib/SearchResultEntryWrapper.cs @@ -168,6 +168,7 @@ public ResolvedSearchResult ResolveBloodHoundInfo() break; case Label.OU: case Label.Container: + case Label.Configuration: case Label.RootCA: case Label.AIACA: case Label.NTAuthStore: