Skip to content

Commit

Permalink
Merge pull request #71 from BloodHoundAD/container-logic-update
Browse files Browse the repository at this point in the history
BED-3868: Build contains edges from DNs
  • Loading branch information
JonasBK authored Nov 9, 2023
2 parents a9bd691 + a0996c1 commit af9529b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Producers/BaseProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected LDAPData CreateLDAPData()
{
if ((methods & ResolvedCollectionMethod.Container) != 0)
{
query = query.AddContainers().AddDomains();
query = query.AddComputers().AddContainers().AddUsers().AddGroups().AddDomains().AddOUs().AddGPOs();
props.AddRange(CommonProperties.ContainerProps);
}

Expand Down
21 changes: 17 additions & 4 deletions src/Runtime/ObjectProcessors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ private async Task<User> ProcessUserObject(ISearchResultEntry entry,
ret.SPNTargets = targets.ToArray();
}

if ((_methods & ResolvedCollectionMethod.Container) != 0)
{
ret.ContainedBy = _containerProcessor.GetContainingObject(entry.DistinguishedName);
}

return ret;
}

Expand Down Expand Up @@ -183,6 +188,11 @@ private async Task<Computer> ProcessComputerObject(ISearchResultEntry entry,
ret.DumpSMSAPassword = computerProps.DumpSMSAPassword;
}

if ((_methods & ResolvedCollectionMethod.Container) != 0)
{
ret.ContainedBy = _containerProcessor.GetContainingObject(entry.DistinguishedName);
}

if (!_methods.IsComputerCollectionSet())
return ret;

Expand Down Expand Up @@ -306,6 +316,11 @@ private Group ProcessGroupObject(ISearchResultEntry entry,
}
}

if ((_methods & ResolvedCollectionMethod.Container) != 0)
{
ret.ContainedBy = _containerProcessor.GetContainingObject(entry.DistinguishedName);
}

return ret;
}

Expand Down Expand Up @@ -368,7 +383,6 @@ private async Task<Domain> ProcessDomainObject(ISearchResultEntry entry,

if ((_methods & ResolvedCollectionMethod.Container) != 0)
{
ret.ChildObjects = _containerProcessor.GetContainerChildObjects(resolvedSearchResult, entry).ToArray();
ret.Links = _containerProcessor.ReadContainerGPLinks(resolvedSearchResult, entry).ToArray();
}

Expand Down Expand Up @@ -410,7 +424,6 @@ private GPO ProcessGPOObject(ISearchResultEntry entry,
ret.Properties);
}
}


return ret;
}
Expand Down Expand Up @@ -447,7 +460,7 @@ private async Task<OU> ProcessOUObject(ISearchResultEntry entry,

if ((_methods & ResolvedCollectionMethod.Container) != 0)
{
ret.ChildObjects = _containerProcessor.GetContainerChildObjects(resolvedSearchResult, entry).ToArray();
ret.ContainedBy = _containerProcessor.GetContainingObject(entry.DistinguishedName);
ret.Properties.Add("blocksinheritance",
ContainerProcessor.ReadBlocksInheritance(entry.GetProperty("gpoptions")));
ret.Links = _containerProcessor.ReadContainerGPLinks(resolvedSearchResult, entry).ToArray();
Expand Down Expand Up @@ -477,7 +490,7 @@ private Container ProcessContainerObject(ISearchResultEntry entry,
ret.Properties.Add("highvalue", false);

if ((_methods & ResolvedCollectionMethod.Container) != 0)
ret.ChildObjects = _containerProcessor.GetContainerChildObjects(entry.DistinguishedName).ToArray();
ret.ContainedBy = _containerProcessor.GetContainingObject(entry.DistinguishedName);

if ((_methods & ResolvedCollectionMethod.ACL) != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Writers/JsonDataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class JsonDataWriter<T> : BaseWriter<T>
private string _fileName;
private JsonSerializerSettings _serializerSettings;

private const int DataVersion = 5;
private const int DataVersion = 6;

/// <summary>
/// Creates a new instance of a JSONWriter using the specified datatype and program context
Expand Down

0 comments on commit af9529b

Please sign in to comment.