-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathplugins.go
55 lines (46 loc) · 1.05 KB
/
plugins.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
package plugins
import (
"fmt"
"net"
)
// Plugin ...
type Plugin interface {
Auto() bool // execute automatically on startup
Execute(c net.Conn) // execute
Name() string // name
Description() string //description
}
var plugins = map[string]Plugin{}
// Init Initializes the plugin system
func Init(c net.Conn) {
/* Modify Start */
//flagGrabber := &FlagGrabber{}
plugins = map[string]Plugin{
//flagGrabber.Name(): flagGrabber,
}
/* Modify End */
// execute plugins that run on startup (auto)
c.Write([]byte("\n[*] Auto-Plugins:\n"))
for _, plugin := range plugins {
if plugin.Auto() {
c.Write([]byte(fmt.Sprintf(" - [%s]\n", plugin.Name())))
plugin.Execute(c)
}
}
}
// Execute ...
func Execute(pluginName string, c net.Conn) {
if _, ok := plugins[pluginName]; ok {
plugins[pluginName].Execute(c)
} else {
c.Write([]byte("[!] Plugin does not exist\n"))
}
}
// List ...
func List() []string {
result := []string{}
for _, plugin := range plugins {
result = append(result, plugin.Name())
}
return result
}