-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
202 lines (169 loc) · 3.99 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli"
)
var app = cli.NewApp()
func init() {
app.Name = "Malware Cli"
app.Description = `Detection validation tool.
The objective is to generate event with specific conditions to validate detection rule.
You can execute commands such as w3wp.exe spawning shell or winword creating file or making DNS queries.`
}
func main() {
app.Commands = []cli.Command{
{
Name: "argsfree",
Usage: "Accept any commandline",
Action: func(c *cli.Context) {
fmt.Println(os.Args)
},
},
{
Name: "connect",
Usage: "Connect to host",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
Usage: "hostname or IP Address",
Required: true,
},
&cli.StringFlag{
Name: "port",
Usage: "port number",
Required: true,
},
},
Action: func(c *cli.Context) {
connectToHost(c.String("host"), c.String("port"))
},
},
{
Name: "download",
Usage: "Download file",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "url",
Usage: "File URL",
Required: true,
},
},
Action: func(c *cli.Context) {
downloadFile(c.String("url"))
},
},
{
Name: "dnsquery",
Usage: "Resolve DNS",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
Usage: "hostname to resolve",
Required: true,
},
},
Action: func(c *cli.Context) {
resolve(c.String("host"))
},
},
{
Name: "execute",
Usage: "Execute command with custom commandline and parent process",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "command",
Usage: "Hostname or IP Address",
Required: true,
},
&cli.StringFlag{
Name: "parent",
Usage: "Optinal parent command to execute",
},
&cli.StringFlag{
Name: "arg",
Usage: "Command arguments",
},
&cli.StringFlag{
Name: "copy",
Usage: "Copy to path before execution",
Value: "C:/Users/Public",
},
},
Action: func(c *cli.Context) {
ExecuteCommand(c.String("command"), c.String("arg"), c.String("parent"), c.String("copy"))
},
}, {
Name: "encrypt",
Usage: "encrypt all files in a folder that match a pattern",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Usage: "Folder path",
Required: true,
},
&cli.StringFlag{
Name: "pattern",
Usage: "File name pattern",
},
},
Action: func(c *cli.Context) {
EncryptFiles(c.String("path"), c.String("pattern"))
},
},
{
Name: "createfile",
Usage: "Create file at a spcific path",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "path",
Usage: "full path and file name",
Required: true,
},
&cli.StringFlag{
Name: "binpath",
Usage: "Full path of the binary creating the file. Example: C:/temp/binary.exe",
},
},
Action: func(c *cli.Context) {
filewrite(c.String("path"), c.String("binpath"))
},
},
{
Name: "reg",
Usage: "Add registry key",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "keyname",
Usage: "Key name",
Required: true,
},
&cli.StringFlag{
Name: "keypath",
Usage: "Key path",
Required: true,
},
&cli.StringFlag{
Name: "value",
Usage: "Key value",
},
&cli.StringFlag{
Name: "binpath",
Usage: "Full path of the binary creating the file. Example: C:/temp/binary.exe",
},
&cli.BoolFlag{
Name: "delete",
Usage: "Delete key",
},
},
Action: func(c *cli.Context) {
AddRegistryKey(c.String("keypath"), c.String("keyname"), c.String("value"), c.String("binpath"), c.Bool("delete"))
},
},
}
//log.Println("Received arguments: ", os.Args)
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}