Skip to content

Commit

Permalink
fix: exception when adding keys (#149)
Browse files Browse the repository at this point in the history
fix: couple missing properties
chore: bump version
  • Loading branch information
rvazarkar authored Jul 31, 2024
1 parent 3398b95 commit 1f5e96a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/CommonLib/LdapQueries/CommonProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static class CommonProperties
LDAPProperties.GroupPolicyOptions, LDAPProperties.AllowedToDelegateTo,
LDAPProperties.AllowedToActOnBehalfOfOtherIdentity, LDAPProperties.WhenCreated,
LDAPProperties.HostServiceAccount, LDAPProperties.UnixUserPassword, LDAPProperties.MsSFU30Password,
LDAPProperties.UnicodePassword
LDAPProperties.UnicodePassword, LDAPProperties.ProfilePath, LDAPProperties.ScriptPath
};

public static readonly string[] ContainerProps =
Expand Down
19 changes: 8 additions & 11 deletions src/CommonLib/LdapUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,22 +1402,19 @@ public async IAsyncEnumerable<OutputBase> GetWellKnownPrincipalOutput() {
}

private async IAsyncEnumerable<Group> GetEnterpriseDCGroups() {
var grouped = new Dictionary<string, List<string>>();
var forestSidToName = new Dictionary<string, string>();
var grouped = new ConcurrentDictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
var forestSidToName = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var domainSid in DomainControllers.GroupBy(x => new SecurityIdentifier(x.Key).AccountDomainSid.Value)) {
if (await GetDomainNameFromSid(domainSid.Key) is (true, var domainName) &&
await GetForest(domainName) is (true, var forestName) &&
await GetDomainSidFromDomainName(forestName) is (true, var forestDomainSid)) {
forestSidToName.Add(forestDomainSid, forestName);
if (grouped.ContainsKey(forestDomainSid)) {
foreach (var k in domainSid) {
grouped[forestDomainSid].Add(k.Key);
}
} else {
forestSidToName.TryAdd(forestDomainSid, forestName);
if (!grouped.ContainsKey(forestDomainSid)) {
grouped[forestDomainSid] = new List<string>();
foreach (var k in domainSid) {
grouped[forestDomainSid].Add(k.Key);
}
}

foreach (var k in domainSid) {
grouped[forestDomainSid].Add(k.Key);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/CommonLib/Processors/LdapPropertyProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public async Task<UserProperties> ReadUserProperties(IDirectoryObject entry, str
props.Add("unicodepassword", entry.GetProperty(LDAPProperties.UnicodePassword));
props.Add("sfupassword", entry.GetProperty(LDAPProperties.MsSFU30Password));
props.Add("logonscript", entry.GetProperty(LDAPProperties.ScriptPath));
props.Add("profilepath", entry.GetProperty(LDAPProperties.ProfilePath));

entry.TryGetLongProperty(LDAPProperties.AdminCount, out var ac);
props.Add("admincount", ac != 0);
Expand Down
2 changes: 1 addition & 1 deletion src/CommonLib/SharpHoundCommonLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageDescription>Common library for C# BloodHound enumeration tasks</PackageDescription>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<RepositoryUrl>https://github.com/BloodHoundAD/SharpHoundCommon</RepositoryUrl>
<Version>4.0.3</Version>
<Version>4.0.4</Version>
<AssemblyName>SharpHoundCommonLib</AssemblyName>
<RootNamespace>SharpHoundCommonLib</RootNamespace>
</PropertyGroup>
Expand Down

0 comments on commit 1f5e96a

Please sign in to comment.