Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions cmd/systray/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/rabbitstack/fibratus/pkg/sys"
"github.com/rabbitstack/fibratus/pkg/util/log"
"github.com/rabbitstack/fibratus/pkg/util/signals"
yconfig "github.com/rabbitstack/fibratus/pkg/yara/config"
"github.com/sirupsen/logrus"
"golang.org/x/sys/windows"
)
Expand All @@ -49,8 +50,8 @@ const (
)

var (
className = windows.StringToUTF16Ptr("fibratus")
alertTitle = "Malicious Activity Detected"
className = windows.StringToUTF16Ptr("fibratus")
defaultSystrayTitle = "Malicious Activity Detected"
)

// Msg represents the data exchanged between systray client/server.
Expand All @@ -77,6 +78,24 @@ func (m Msg) decode(output any) error {
return decoder.Decode(m.Data)
}

func systrayTitle(alert alertsender.Alert) string {
switch alert.Title {
case yconfig.MemoryThreatAlertTitle, yconfig.FileThreatAlertTitle:
return alert.Title
default:
return defaultSystrayTitle
}
}

func systrayText(alert alertsender.Alert) string {
switch alert.Title {
case yconfig.MemoryThreatAlertTitle, yconfig.FileThreatAlertTitle:
return alert.Text
default:
return alert.Title
}
}

type Systray struct {
systrayIcon *sys.SystrayIcon
window sys.Hwnd
Expand Down Expand Up @@ -222,7 +241,7 @@ func (s *Systray) handleMessage(m Msg) error {
logrus.Errorf("unable to decode alert: %v", err)
return err
}
return s.systrayIcon.ShowBalloonNotification(alertTitle, alert.Title, s.config.Sound, s.config.QuietMode)
return s.systrayIcon.ShowBalloonNotification(systrayTitle(alert), systrayText(alert), s.config.Sound, s.config.QuietMode)
}
return nil
}
Expand Down
Loading