-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
websites-rm-content.go
54 lines (48 loc) · 1.31 KB
/
websites-rm-content.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
package websites
import (
"context"
"strings"
"github.com/bishopfox/sliver/client/console"
"github.com/bishopfox/sliver/protobuf/clientpb"
"github.com/desertbit/grumble"
)
// WebsitesRmContent - Remove static content from a website
func WebsitesRmContent(ctx *grumble.Context, con *console.SliverConsoleClient) {
name := ctx.Flags.String("website")
webPath := ctx.Flags.String("web-path")
recursive := ctx.Flags.Bool("recursive")
if name == "" {
con.PrintErrorf("Must specify a website name via --website, see --help\n")
return
}
if webPath == "" {
con.PrintErrorf("Must specify a web path via --web-path, see --help\n")
return
}
website, err := con.Rpc.Website(context.Background(), &clientpb.Website{
Name: name,
})
if err != nil {
con.PrintErrorf("%s", err)
return
}
rmWebContent := &clientpb.WebsiteRemoveContent{
Name: name,
Paths: []string{},
}
if recursive {
for contentPath := range website.Contents {
if strings.HasPrefix(contentPath, webPath) {
rmWebContent.Paths = append(rmWebContent.Paths, contentPath)
}
}
} else {
rmWebContent.Paths = append(rmWebContent.Paths, webPath)
}
web, err := con.Rpc.WebsiteRemoveContent(context.Background(), rmWebContent)
if err != nil {
con.PrintErrorf("Failed to remove content %s", err)
return
}
PrintWebsite(web, con)
}