Skip to content
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
5 changes: 3 additions & 2 deletions src/CommonLib/Enums/CollectionMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ public enum CollectionMethod {
WebClientService = 1 << 21,
SmbInfo = 1 << 22,
NTLMRegistry = 1 << 23,
GPOUserRights = 1 << 24,
//TODO: Re-introduce this when we're ready for Event Log collection
//EventLogs = 1 << 23,
LocalGroups = DCOM | RDP | LocalAdmin | PSRemote,
ComputerOnly = LocalGroups | Session | UserRights | CARegistry | DCRegistry | WebClientService | SmbInfo | NTLMRegistry,
DCOnly = ACL | Container | Group | ObjectProps | Trusts | GPOLocalGroup | CertServices,
DCOnly = ACL | Container | Group | ObjectProps | Trusts | GPOLocalGroup | GPOUserRights | CertServices,

Default = Group | Session | Trusts | ACL | ObjectProps | LocalGroups | SPNTargets | Container | CertServices |
LdapServices | SmbInfo | WebClientService,

All = Default | LoggedOn | GPOLocalGroup | UserRights | CARegistry | DCRegistry | WebClientService |
All = Default | LoggedOn | GPOLocalGroup | GPOUserRights | UserRights | CARegistry | DCRegistry | WebClientService |
LdapServices | NTLMRegistry
}
}
2 changes: 1 addition & 1 deletion src/CommonLib/Enums/LSAPrivileges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public class LSAPrivileges
public const string TrustedCredManAccess = "SeTrustedCredManAccessPrivilege";
public const string Undock = "SeUndockPrivilege";

public static readonly string[] DesiredPrivileges = {RemoteInteractiveLogon};
public static readonly string[] DesiredPrivileges = {InteractiveLogon, RemoteInteractiveLogon, AssignPrimaryToken, Backup, CreateToken, Debug, Impersonate, LoadDriver, ManageVolume, Restore, TakeOwnership, Tcb};
}
}
8 changes: 8 additions & 0 deletions src/CommonLib/LdapProducerQueryGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static GeneratedLdapParameters GenerateDefaultPartitionParameters(Collect
if (methods.HasFlag(CollectionMethod.GPOLocalGroup))
properties.AddRange(CommonProperties.GPOLocalGroupProps);

if (methods.HasFlag(CollectionMethod.GPOUserRights))
properties.AddRange(CommonProperties.GPOUserRights);

if (methods.HasFlag(CollectionMethod.SPNTargets))
properties.AddRange(CommonProperties.SPNTargetProps);

Expand Down Expand Up @@ -80,6 +83,11 @@ public static GeneratedLdapParameters GenerateDefaultPartitionParameters(Collect
properties.AddRange(CommonProperties.GPOLocalGroupProps);
}

if (methods.HasFlag(CollectionMethod.GPOUserRights)) {
filter = filter.AddOUs();
properties.AddRange(CommonProperties.GPOUserRights);
}

if (methods.HasFlag(CollectionMethod.DCRegistry) || methods.HasFlag(CollectionMethod.LdapServices)) {
filter = filter.AddComputers(CommonFilters.DomainControllers);
properties.AddRange(CommonProperties.ComputerMethodProps);
Expand Down
4 changes: 4 additions & 0 deletions src/CommonLib/LdapQueries/CommonProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public static class CommonProperties
LDAPProperties.GPLink, LDAPProperties.Name
};

public static readonly string[] GPOUserRights = {
LDAPProperties.GPLink, LDAPProperties.Name
};

public static readonly string[] CertAbuseProps =
{
LDAPProperties.CertificateTemplates, LDAPProperties.Flags, LDAPProperties.DNSHostName, LDAPProperties.CACertificate, LDAPProperties.PKINameFlag,
Expand Down
4 changes: 3 additions & 1 deletion src/CommonLib/OutputTypes/OU.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using SharpHoundCommonLib.Processors;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Remove unnecessary using directive.

The using SharpHoundCommonLib.Processors directive appears unused. ResultingGPOUserRights is in the SharpHoundCommonLib.OutputTypes namespace (same as this file), so this using directive is not needed.

🤖 Prompt for AI Agents
In src/CommonLib/OutputTypes/OU.cs around lines 1 to 1, remove the unused using
directive "using SharpHoundCommonLib.Processors" because ResultingGPOUserRights
resides in the same SharpHoundCommonLib.OutputTypes namespace; simply delete
that using line from the top of the file so only necessary directives remain.

using System;

namespace SharpHoundCommonLib.OutputTypes
{
public class OU : OutputBase
{
public ResultingGPOChanges GPOChanges = new();
public ResultingGPOUserRights GPOUserRights = new();
public GPLink[] Links { get; set; } = Array.Empty<GPLink>();
public TypedPrincipal[] ChildObjects { get; set; } = Array.Empty<TypedPrincipal>();
public string[] InheritanceHashes { get; set; } = Array.Empty<string>();
Expand Down
14 changes: 14 additions & 0 deletions src/CommonLib/OutputTypes/ResultingGPOUserRights.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;

namespace SharpHoundCommonLib.OutputTypes
{
public class ResultingGPOUserRights
{
public TypedPrincipal[] AffectedComputers { get; set; } = Array.Empty<TypedPrincipal>();

// Dictionary mapping privilege name to array of principals that have that privilege
public Dictionary<string, TypedPrincipal[]> UserRightAssignments { get; set; } =
new Dictionary<string, TypedPrincipal[]>();
}
}
2 changes: 1 addition & 1 deletion src/CommonLib/Processors/GPOLocalGroupProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Task<ResultingGPOChanges> ReadGPOLocalGroups(IDirectoryObject entry) {
return Task.FromResult(new ResultingGPOChanges());
}

public async Task<ResultingGPOChanges> ReadGPOLocalGroups(string gpLink, string distinguishedName) {
public async Task<ResultingGPOChanges> ReadGPOLocalGroups(string gpLink, string distinguishedName) {
var ret = new ResultingGPOChanges();
//If the gplink property is null, we don't need to process anything
if (gpLink == null)
Expand Down
Loading