Skip to content

Commit

Permalink
Fix for AdminSDHolder analyzer in multi-domain analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed May 5, 2022
1 parent 936dd44 commit 1aaff27
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modules/integrations/activedirectory/analyze/analyze-ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,25 +1004,30 @@ func init() {
return strings.HasPrefix(o.OneAttrString(engine.DistinguishedName), "CN=AdminSDHolder,CN=System,")
}).Slice() {
// We found it - so we know it can change ACLs of some objects
rootdn := adminsdholder.OneAttrString(engine.DistinguishedName)[27:]
domainpart := adminsdholder.OneAttrString(engine.DomainPart)

// Are some groups excluded?
excluded_mask := 0

// Find dsHeuristics, this defines groups EXCLUDED From AdminSDHolder application
// https://social.technet.microsoft.com/wiki/contents/articles/22331.adminsdholder-protected-groups-and-security-descriptor-propagator.aspx#What_is_a_protected_group
if ds, found := ao.Find(engine.DistinguishedName, engine.AttributeValueString("CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,"+rootdn)); found {
if ds, found := ao.Find(engine.DistinguishedName, engine.AttributeValueString("CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,"+domainpart)); found {
excluded := ds.OneAttrString(activedirectory.DsHeuristics)
if len(excluded) >= 16 {
excluded_mask = strings.Index("0123456789ABCDEF", strings.ToUpper(string(excluded[15])))
}
}

for _, o := range ao.Filter(func(o *engine.Object) bool {
// Check if object is a user account
// Check if object is a group
if o.Type() != engine.ObjectTypeGroup {
return false
}

// Only this "local" AD (for multi domain analysis)
if o.OneAttrString(engine.DomainPart) != domainpart {
return false
}
return true
}).Slice() {

Expand All @@ -1031,11 +1036,6 @@ func init() {
continue
}

// Only this "local" AD (for multi domain analysis)
if !strings.HasSuffix(o.OneAttrString(engine.DistinguishedName), rootdn) {
continue
}

switch grpsid.RID() {
case DOMAIN_USER_RID_ADMIN:
case DOMAIN_USER_RID_KRBTGT:
Expand Down

0 comments on commit 1aaff27

Please sign in to comment.