-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (48 loc) · 1009 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
winlog "github.com/bi-zone/gowinlog"
)
func inEvtIds(id uint64, evtIds []uint64) bool {
for _, confId := range evtIds {
if confId == id {
return true
}
}
return false
}
func main() {
conf := loadConfig()
teleBot := newTelegramBot(conf.TelegramBotToken, conf.TelegramChannelId)
teleBot.run()
teleBot.sendMsg("started")
watcher, err := winlog.NewWinLogWatcher()
if err != nil {
teleBot.sendMsg(err.Error())
return
}
if conf.EnableSysmon {
err = watcher.SubscribeFromNow("Microsoft-Windows-Sysmon/Operational", "*")
if err != nil {
teleBot.sendMsg(err.Error())
return
}
}
err = watcher.SubscribeFromNow("Security", "*")
if err != nil {
teleBot.sendMsg(err.Error())
return
}
for {
select {
case evt := <-watcher.Event():
switch evt.Channel {
case "Security":
if inEvtIds(evt.EventId, conf.EvtIds) {
teleBot.sendMsg(evt.Msg)
}
case "Microsoft-Windows-Sysmon/Operational":
teleBot.sendMsg(evt.Msg)
}
}
}
}