Skip to content

Commit

Permalink
Fixed problem with local users that are deleted since they logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Nov 5, 2021
1 parent de15566 commit 4a17008
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions modules/integrations/localmachine/analyze/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ func ImportCollectorInfo(cinfo localmachine.Info, ao *engine.Objects) error {
usersid = localsid.AddComponent(usersid.RID())
}

user, _ := ao.FindOrAdd(
user, _ := ao.MergeOrAdd(
activedirectory.ObjectSid, engine.AttributeValueSID(usersid),
engine.DownLevelLogonName, engine.AttributeValueString(login.Name),
)

if !strings.HasSuffix(login.Name, "\\") {
user.Set(engine.DownLevelLogonName, engine.AttributeValueString(login.Name))
}

computerobject.Pwns(user, PwnLocalSessionLastDay)
}

Expand All @@ -272,10 +276,14 @@ func ImportCollectorInfo(cinfo localmachine.Info, ao *engine.Objects) error {
usersid = localsid.AddComponent(usersid.RID())
}

user, _ := ao.FindOrAdd(
user, _ := ao.MergeOrAdd(
activedirectory.ObjectSid, engine.AttributeValueSID(usersid),
engine.DownLevelLogonName, engine.AttributeValueString(login.Name),
)

if !strings.HasSuffix(login.Name, "\\") {
user.Set(engine.DownLevelLogonName, engine.AttributeValueString(login.Name))
}

computerobject.Pwns(user, PwnLocalSessionLastWeek)
}

Expand All @@ -294,10 +302,14 @@ func ImportCollectorInfo(cinfo localmachine.Info, ao *engine.Objects) error {
usersid = localsid.AddComponent(usersid.RID())
}

user, _ := ao.FindOrAdd(
user, _ := ao.MergeOrAdd(
activedirectory.ObjectSid, engine.AttributeValueSID(usersid),
engine.DownLevelLogonName, engine.AttributeValueString(login.Name),
)

if !strings.HasSuffix(login.Name, "\\") {
user.Set(engine.DownLevelLogonName, engine.AttributeValueString(login.Name))
}

computerobject.Pwns(user, PwnLocalSessionLastMonth)
}

Expand Down

0 comments on commit 4a17008

Please sign in to comment.