forked from 0xrawsec/whids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiocs.go
45 lines (40 loc) · 1.51 KB
/
iocs.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
package agent
import (
"fmt"
"github.com/0xrawsec/gene/v2/engine"
"github.com/0xrawsec/whids/api/server"
)
var (
IoCRules = []engine.Rule{
ruleHashIoC(),
ruleDomainIoC(),
}
)
func ruleHashIoC() (r engine.Rule) {
r = engine.NewRule()
r.Name = "Builtin:HashIoC"
// FileCreate, FileDeleted and FileDeletedDetected
r.Meta.Events = map[string][]int64{"Microsoft-Windows-Sysmon/Operational": {1, 6, 7}}
r.Meta.Criticality = 10
r.Matches = []string{
fmt.Sprintf("$ioc_md5: extract('MD5=(?P<md5>[A-F0-9]{32})', Hashes) in %s", server.IoCContainerName),
fmt.Sprintf("$ioc_sha1: extract('SHA1=(?P<sha1>[A-F0-9]{40})', Hashes) in %s", server.IoCContainerName),
fmt.Sprintf("$ioc_sha256: extract('SHA256=(?P<sha256>[A-F0-9]{64})', Hashes) in %s", server.IoCContainerName),
}
r.Condition = "$ioc_md5 or $ioc_sha1 or $ioc_sha256"
return
}
func ruleDomainIoC() (r engine.Rule) {
r = engine.NewRule()
r.Name = "Builtin:DomainIoC"
// FileCreate, FileDeleted and FileDeletedDetected
r.Meta.Events = map[string][]int64{"Microsoft-Windows-Sysmon/Operational": {22}}
r.Meta.Criticality = 10
r.Matches = []string{
fmt.Sprintf("$ioc_domain: extract('(?P<dom>\\w+\\.\\w+$)',QueryName) in %s'", server.IoCContainerName),
fmt.Sprintf("$ioc_subdomain: extract('(?P<sub>\\w+\\.\\w+\\.\\w+$)',QueryName) in %s'", server.IoCContainerName),
fmt.Sprintf("$ioc_hostname: extract('(?P<subsub>\\w+\\.\\w+\\.\\w+\\.\\w+$)',QueryName) in %s'", server.IoCContainerName),
}
r.Condition = "$ioc_domain or $ioc_subdomain or $ioc_hostname"
return
}