Skip to content

Commit

Permalink
Fixed issues:
Browse files Browse the repository at this point in the history
  • Loading branch information
qjerome committed Oct 22, 2019
1 parent e13de70 commit 93508ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
1 change: 1 addition & 0 deletions collector/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ func (f *Forwarder) ProcessQueue() {
fd.Close()
case strings.HasSuffix(fp, ".log.1"), strings.HasSuffix(fp, ".log"):
err = f.Client.PostLogs(fd)
fd.Close()
}

// We do not remove the logs if we failed to send
Expand Down
65 changes: 36 additions & 29 deletions tools/whids/hookdefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type processTrack struct {
PID int64
CommandLine string
ParentCommandLine string
CurrentDirectory string
ProcessGUID string
User string
ParentUser string
Expand Down Expand Up @@ -359,36 +360,39 @@ func hookTrack(e *evtx.GoEvtxMap) {
if pguid, err := e.GetString(&pathSysmonParentProcessGUID); err == nil {
if user, err := e.GetString(&pathSysmonUser); err == nil {
if il, err := e.GetString(&pathSysmonIntegrityLevel); err == nil {
track := &processTrack{
Image: image,
ParentImage: pImage,
CommandLine: commandLine,
ParentCommandLine: pCommandLine,
PID: pid,
User: user,
IntegrityLevel: il,
ProcessGUID: guid,
ParentProcessGUID: pguid,
History: make([]string, 0),
Stats: stats{0, 0, 0, make(map[string]*int64)},
}
if parent := processTracker.GetByGuid(pguid); parent != nil {
track.History = append(parent.History, parent.Image)
track.ParentUser = parent.User
track.ParentIntegrityLevel = parent.IntegrityLevel
} else {
// For processes created by System
if pimage, err := e.GetString(&pathSysmonParentImage); err == nil {
track.History = append(track.History, pimage)
if cd, err := e.GetString(&pathSysmonCurrentDirectory); err == nil {
track := &processTrack{
Image: image,
ParentImage: pImage,
CommandLine: commandLine,
ParentCommandLine: pCommandLine,
CurrentDirectory: cd,
PID: pid,
User: user,
IntegrityLevel: il,
ProcessGUID: guid,
ParentProcessGUID: pguid,
History: make([]string, 0),
Stats: stats{0, 0, 0, make(map[string]*int64)},
}
if parent := processTracker.GetByGuid(pguid); parent != nil {
track.History = append(parent.History, parent.Image)
track.ParentUser = parent.User
track.ParentIntegrityLevel = parent.IntegrityLevel
} else {
// For processes created by System
if pimage, err := e.GetString(&pathSysmonParentImage); err == nil {
track.History = append(track.History, pimage)
}
}
processTracker.Add(track)
e.Set(&pathAncestors, strings.Join(track.History, "|"))
if track.ParentUser != "" {
e.Set(&pathParentUser, track.ParentUser)
}
if track.ParentIntegrityLevel != "" {
e.Set(&pathParentIntegrityLevel, track.ParentIntegrityLevel)
}
}
processTracker.Add(track)
e.Set(&pathAncestors, strings.Join(track.History, "|"))
if track.ParentUser != "" {
e.Set(&pathParentUser, track.ParentUser)
}
if track.ParentIntegrityLevel != "" {
e.Set(&pathParentIntegrityLevel, track.ParentIntegrityLevel)
}
}
}
Expand Down Expand Up @@ -766,9 +770,11 @@ func hookEnrichAnySysmon(e *evtx.GoEvtxMap) {

default:
hasComLine := true

// Default Values for the fields
e.Set(&pathSysmonUser, "?")
e.Set(&pathSysmonIntegrityLevel, "?")
e.Set(&pathSysmonCurrentDirectory, "?")

if _, err := e.GetString(&pathSysmonCommandLine); err != nil {
e.Set(&pathSysmonCommandLine, "?")
Expand All @@ -783,6 +789,7 @@ func hookEnrichAnySysmon(e *evtx.GoEvtxMap) {
}
e.Set(&pathSysmonUser, track.User)
e.Set(&pathSysmonIntegrityLevel, track.IntegrityLevel)
e.Set(&pathSysmonCurrentDirectory, track.CurrentDirectory)
}
}
}
Expand Down

0 comments on commit 93508ea

Please sign in to comment.