forked from mdsecactivebreach/o365-attack-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
71 lines (51 loc) · 1.13 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"encoding/json"
"fmt"
"gopkg.in/gcfg.v1"
"io/ioutil"
"log"
"o365-attack-toolkit/model"
"o365-attack-toolkit/server"
"os"
"path/filepath"
_ "database/sql"
_"github.com/mattn/go-sqlite3"
)
func main(){
model.GlbConfig = model.Config{}
err := gcfg.ReadFileInto(&model.GlbConfig,"template.conf")
if err != nil {
log.Fatal(err.Error())
}
initializeRules()
go server.StartExtServer(model.GlbConfig)
server.StartIntServer(model.GlbConfig)
fmt.Println(model.GlbConfig)
}
func initializeRules(){
var ruleFiles []string
var tempRule model.Rule
root := "rules"
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
return nil
}
ruleFiles = append(ruleFiles, path)
return nil
})
if err != nil {
panic(err)
}
for _, file := range ruleFiles {
ruleFile, err := os.Open(file)
if err != nil {
log.Println(err)
}
defer ruleFile.Close()
byteValue, _ := ioutil.ReadAll(ruleFile)
json.Unmarshal(byteValue,&tempRule)
model.GlbRules = append(model.GlbRules,tempRule)
}
log.Printf("Loaded %d rules successfully.",len(model.GlbRules))
}