forked from maliceio/malice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.go
156 lines (150 loc) · 3.86 KB
/
commands.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package commands
import (
"fmt"
"os"
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
)
var tasks = []string{"start", "stop"}
// Commands are the codegangsta/cli commands for Malice
var Commands = []cli.Command{
{
Name: "scan",
Usage: "Scan a file",
Description: "File to be scanned.",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "logs",
Usage: "Display the Logs of the Plugin containers",
},
},
Action: func(c *cli.Context) error { return cmdScan(c.Args().First(), c.Bool("logs")) },
},
{
Name: "watch",
Usage: "Watch a folder",
Description: "Folder to be watched.",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "logs",
Usage: "Display the Logs of the Plugin containers",
},
},
Action: func(c *cli.Context) error { return cmdWatch(c.Args().First(), c.Bool("logs")) },
},
{
Name: "lookup",
Usage: "Look up a file hash (md5/sha1)",
ArgsUsage: "hash of file to lookup `HASH`",
// Description: "Hash to be queried.",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "logs",
Usage: "Display the Logs of the Plugin containers",
},
},
Action: func(c *cli.Context) error {
if c.Args().Present() {
return cmdLookUp(c.Args().First(), c.Bool("logs"))
}
log.Error("Please supply a MD5/SHA1 hash to query.")
return nil
},
},
{
Name: "elk",
Usage: "Start the ELK docker container",
Description: "This ELK container will attach to the ElasticSearch data for all previous malice scans.",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "logs",
Usage: "Display the Logs from the ELK Container",
},
},
Action: func(c *cli.Context) error { return cmdELK(c.Bool("logs")) },
},
// {
// Name: "web",
// Usage: "Start, Stop Web services",
// Subcommands: []cli.Command{
// {
// Name: "start",
// Usage: "start web application",
// Action: func(c *cli.Context) error { return cmdWebStart() },
// },
// {
// Name: "stop",
// Usage: "stop web application",
// Action: func(c *cli.Context) error { return cmdWebStop() },
// },
// },
// BashComplete: func(c *cli.Context) {
// // This will complete if no args are passed
// if len(c.Args()) > 0 {
// return
// }
// for _, t := range tasks {
// fmt.Println(t)
// }
// },
// },
{
Name: "plugin",
Usage: "List, Install or Remove Plugins",
Subcommands: []cli.Command{
{
Name: "list",
Usage: "list enabled installed plugins",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "all",
Usage: "display all installed plugins",
},
cli.BoolFlag{
Name: "detail,d",
Usage: "display plugin details",
},
},
Action: func(c *cli.Context) error { return cmdListPlugins(c.Bool("all"), c.Bool("detail")) },
},
{
Name: "install",
Usage: "install plugin",
Action: func(c *cli.Context) error { return cmdInstallPlugin(c.Args().First()) },
},
{
Name: "remove",
Usage: "remove plugin",
Action: func(c *cli.Context) error { return cmdRemovePlugin(c.Args().First()) },
},
{
Name: "update",
Usage: "update plugin",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "all",
Usage: "update all installed plugins",
},
cli.BoolFlag{
Name: "s,source",
Usage: "update plugin from source repo",
},
},
Action: func(c *cli.Context) error { return cmdUpdatePlugin(c.Args().First(), c.Bool("all"), c.Bool("source")) },
},
},
BashComplete: func(c *cli.Context) {
// This will complete if no args are passed
if len(c.Args()) > 0 {
return
}
for _, t := range tasks {
fmt.Println(t)
}
},
},
}
// CmdNotFound outputs a formatted command not found message
func CmdNotFound(c *cli.Context, command string) {
log.Fatalf("%s: '%s' is not a %s command. See '%s --help'.", c.App.Name, command, c.App.Name, os.Args[0])
}