-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
implants.go
102 lines (89 loc) · 2.81 KB
/
implants.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
package command
/*
Sliver Implant Framework
Copyright (C) 2019 Bishop Fox
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import (
"bytes"
"context"
"fmt"
"strings"
"text/tabwriter"
consts "github.com/bishopfox/sliver/client/constants"
"github.com/bishopfox/sliver/protobuf/clientpb"
"github.com/bishopfox/sliver/protobuf/commonpb"
"github.com/bishopfox/sliver/protobuf/rpcpb"
"github.com/desertbit/grumble"
)
func listImplantBuilds(ctx *grumble.Context, rpc rpcpb.SliverRPCClient) {
builds, err := rpc.ImplantBuilds(context.Background(), &commonpb.Empty{})
if err != nil {
fmt.Printf(Warn+"%s\n", err)
return
}
if 0 < len(builds.Configs) {
displayAllImplantBuilds(builds.Configs)
} else {
fmt.Printf(Info + "No implant builds\n")
}
}
func rmImplantBuild(ctx *grumble.Context, rpc rpcpb.SliverRPCClient) {
if len(ctx.Args) < 1 {
fmt.Printf(Warn+"Invalid implant name, see `%s %s --help`\n", consts.ImplantBuildsStr, consts.RmStr)
return
}
_, err := rpc.DeleteImplantBuild(context.Background(), &clientpb.DeleteReq{
Name: ctx.Args[0],
})
if err != nil {
fmt.Printf(Warn+"Failed to delete implant %s\n", err)
return
}
}
func displayAllImplantBuilds(configs map[string]*clientpb.ImplantConfig) {
outputBuf := bytes.NewBufferString("")
table := tabwriter.NewWriter(outputBuf, 0, 2, 2, ' ', 0)
fmt.Fprintf(table, "Name\tOS/Arch\tDebug\tFormat\tCommand & Control\t\n")
fmt.Fprintf(table, "%s\t%s\t%s\t%s\t%s\t\n",
strings.Repeat("=", len("Name")),
strings.Repeat("=", len("OS/Arch")),
strings.Repeat("=", len("Debug")),
strings.Repeat("=", len("Format")),
strings.Repeat("=", len("Command & Control")),
)
for sliverName, config := range configs {
if 0 < len(config.C2) {
fmt.Fprintf(table, "%s\t%s\t%s\t%s\t%s\t\n",
sliverName,
fmt.Sprintf("%s/%s", config.GOOS, config.GOARCH),
fmt.Sprintf("%v", config.Debug),
config.Format,
fmt.Sprintf("[1] %s", config.C2[0].URL),
)
}
if 1 < len(config.C2) {
for index, c2 := range config.C2[1:] {
fmt.Fprintf(table, "%s\t%s\t%s\t%s\t%s\t\n",
"",
"",
"",
"",
fmt.Sprintf("[%d] %s", index+2, c2.URL),
)
}
}
fmt.Fprintf(table, "%s\t%s\t%s\t%s\t%s\t\n", "", "", "", "", "")
}
table.Flush()
fmt.Printf(outputBuf.String())
}