Skip to content

Commit

Permalink
Added combined WSUS/SCCM edge as "ControlsUpdates"
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed May 6, 2022
1 parent 8923752 commit 610c12f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 11 deletions.
2 changes: 0 additions & 2 deletions modules/engine/loaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/rs/zerolog/log"
)

const PostProcessing LoaderID = -1

type LoaderID int

type Loader interface {
Expand Down
21 changes: 16 additions & 5 deletions modules/integrations/localmachine/analyze/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ var (

PwnSIDCollision = engine.NewPwn("SIDCollision")

DNSHostname = engine.NewAttribute("dnsHostName")
PwnPatches = engine.NewPwn("Patches")
DNSHostname = engine.NewAttribute("dnsHostName")
PwnControlsUpdates = engine.NewPwn("ControlsUpdates")
WUServer = engine.NewAttribute("wuServer")
SCCMServer = engine.NewAttribute("sccmServer")
)

func MapSID(original, new, input windowssecurity.SID) windowssecurity.SID {
Expand Down Expand Up @@ -101,10 +103,19 @@ func (ld *LocalMachineLoader) ImportCollectorInfo(cinfo localmachine.Info) error

if cinfo.Machine.WUServer != "" {
if u, err := url.Parse(cinfo.Machine.WUServer); err == nil {
wsusserver, _ := ld.ao.FindOrAdd(
DNSHostname, engine.AttributeValueString(u.Host),
host, _, _ := strings.Cut(u.Host, ":")
computerobject.SetFlex(
WUServer, engine.AttributeValueString(host),
)
}
}

if cinfo.Machine.SCCMLastValidMP != "" {
if u, err := url.Parse(cinfo.Machine.SCCMLastValidMP); err == nil {
host, _, _ := strings.Cut(u.Host, ":")
computerobject.SetFlex(
SCCMServer, engine.AttributeValueString(host),
)
wsusserver.Pwns(computerobject, PwnPatches)
}
}

Expand Down
43 changes: 43 additions & 0 deletions modules/integrations/localmachine/analyze/analyzers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package analyze

import (
"github.com/lkarlslund/adalanche/modules/engine"
"github.com/rs/zerolog/log"
)

func init() {
loader.AddProcessor(
func(ao *engine.Objects) {
for _, o := range ao.Slice() {
if o.HasAttr(WUServer) || o.HasAttr(SCCMServer) {
var hosts []string
if hostname := o.OneAttrString(WUServer); hostname != "" {
hosts = append(hosts, hostname)
}

if hostname := o.OneAttrString(SCCMServer); hostname != "" {
hosts = append(hosts, hostname)
}

for _, host := range hosts {
servers, found := ao.FindTwoMultiOrAdd(
DNSHostname, engine.AttributeValueString(host),
engine.ObjectClass, engine.AttributeValueString("computer"),
nil,
)
if !found {
log.Warn().Msgf("Could not find controlling WSUS or SCCM server %v for %v", host, o.DN())
continue
}
for _, server := range servers {
server.Pwns(o, PwnControlsUpdates)
}
}
}
}
},
"Link SCCM and WSUS servers to controlled computers",
engine.AfterMerge,
)

}
6 changes: 3 additions & 3 deletions modules/integrations/localmachine/analyze/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

const loadername = "LocalMachine JSON file"

func init() {
engine.AddLoader(func() engine.Loader { return &LocalMachineLoader{} })
}
var (
loader = engine.AddLoader(func() engine.Loader { return &LocalMachineLoader{} })
)

type LocalMachineLoader struct {
ao *engine.Objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func init() {
engine.PostProcessing.AddProcessor(func(ao *engine.Objects) {
loader.AddProcessor(func(ao *engine.Objects) {
var warns int
ln := engine.AttributeValueString(loadername)
for _, o := range ao.Slice() {
Expand Down

0 comments on commit 610c12f

Please sign in to comment.