forked from mdsecactivebreach/o365-attack-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
98 lines (73 loc) · 2.19 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
_ "database/sql"
"flag"
"fmt"
//"github.com/sirupsen/logrus"
"github.com/vitorallo/o365-attack-toolkit/logging"
"github.com/vitorallo/o365-attack-toolkit/model"
"github.com/vitorallo/o365-attack-toolkit/server"
_ "github.com/mattn/go-sqlite3"
"gopkg.in/gcfg.v1"
)
var (
configFile = flag.String("c", "template.conf", "Configuration template")
LogOutput = flag.String("o", "", "Write session and logs to a file")
IntServerUp = flag.Bool("i", true, "Enable internal HTTP GUI server <default: true>")
ApiServerUp = flag.Bool("a", false, "Enable REST API GUI server <default: false>")
debug_mode = flag.String("d", "error", "Set debug level <error: default, debug, trace>")
)
func main() {
flag.Parse()
model.GlbConfig = model.Config{}
err := gcfg.ReadFileInto(&model.GlbConfig, *configFile)
if err != nil {
fmt.Printf("Fatal error reding config file: %v", err.Error())
return
}
//setting logging environment
Log := logging.NewLogger(*debug_mode)
Log.Trace(model.GlbConfig)
//initializeRules()
//staring external server
Log.Debug("Starting with oauth token redirect URI: ", model.GlbConfig.Oauth.Redirecturi)
go server.StartExtServer(model.GlbConfig, logging.GetLogger())
if *ApiServerUp {
Log.Debug("Starting REST API GUI")
server.StartAPIServer(model.GlbConfig, logging.GetLogger())
} else if !*IntServerUp {
Log.Fatal("Internal or API GUI, one of the two must be enabled!")
} else {
Log.Debug("Starting internal HTTP GUI")
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))
}
**/