This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 269
/
main.go
91 lines (76 loc) · 1.85 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
package main
import (
"fmt"
"os"
"runtime"
"strconv"
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
"github.com/maliceio/malice/commands"
"github.com/maliceio/malice/config"
"github.com/maliceio/malice/malice/logger"
"github.com/maliceio/malice/malice/maldirs"
"github.com/maliceio/malice/plugins"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func init() {
logger.Init(version)
setDebugOutputLevel()
config.Load(version)
plugins.Load()
}
func setDebugOutputLevel() {
for _, f := range os.Args {
if f == "-D" || f == "--debug" || f == "-debug" {
log.SetLevel(log.DebugLevel)
}
}
debugEnv := os.Getenv("MALICE_DEBUG")
if debugEnv != "" {
showDebug, err := strconv.ParseBool(debugEnv)
if err != nil {
fmt.Fprintf(os.Stderr, "Error parsing boolean value from MALICE_DEBUG: %s\n", err)
os.Exit(1)
}
if showDebug {
log.SetLevel(log.DebugLevel)
}
}
}
// Init initializes Malice
func Init() {
maldirs.MakeDirs()
}
func main() {
log.Debugf("Using %d PROCS", runtime.NumCPU())
runtime.GOMAXPROCS(runtime.NumCPU())
Init()
// setDebugOutputLevel()
cli.AppHelpTemplate = commands.AppHelpTemplate
cli.CommandHelpTemplate = commands.CommandHelpTemplate
app := cli.NewApp()
app.Name = "malice"
app.Author = "blacktop"
app.Email = "https://github.com/blacktop"
app.Commands = commands.Commands
app.CommandNotFound = commands.CmdNotFound
app.Usage = "Open Source Malware Analysis Framework"
app.Version = fmt.Sprintf("%v, commit %v, built at %v", version, commit, date)
app.Copyright = "Copyright (c) 2013 - 2023 'blacktop'"
// app.EnableBashCompletion = true
log.Debug("Malice Version: ", app.Version)
app.Flags = []cli.Flag{
cli.BoolFlag{
EnvVar: "MALICE_DEBUG",
Name: "debug, D",
Usage: "Enable debug mode",
},
}
if err := app.Run(os.Args); err != nil {
log.Fatalln(err)
}
}