-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmod-branding.go
More file actions
65 lines (54 loc) · 1.68 KB
/
Copy pathmod-branding.go
File metadata and controls
65 lines (54 loc) · 1.68 KB
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
package main
import (
"cloak/pkg/subs"
"fmt"
"path/filepath"
)
type SearchReplacePair struct {
search string
replace string
}
type BrandingModule struct {
ignoreList []string
renamePaths bool
replacePairs []SearchReplacePair
}
func NewBrandingModule() *BrandingModule {
return &BrandingModule{
ignoreList: []string{".git", ".github", "docs", "vendor"},
renamePaths: true,
replacePairs: []SearchReplacePair{
{search: "sliver", replace: "gunner"},
{search: "Sliver", replace: "Gunner"},
{search: "SLIVER", replace: "GUNNER"},
{search: "beacon", replace: "lazer"},
{search: "Beacon", replace: "Lazer"},
{search: "BEACON", replace: "LAZER"},
{search: "bishopfox", replace: "knightbruce"},
{search: "BishopFox", replace: "KnightBruce"},
},
}
}
func (m *BrandingModule) Name() string {
return "branding"
}
func (m *BrandingModule) Run(config *Config, verbose bool) error {
startPath := filepath.Join(config.RunDir, "sliver")
// Start the recursive search and replace
var err error
for _, pair := range m.replacePairs {
err = subs.SearchAndReplace(startPath, pair.search, pair.replace, m.ignoreList, verbose)
if err != nil {
return fmt.Errorf("[branding] [SearchAndReplace] error during execution: %v", err)
}
err = subs.SearchAndRenameFiles(startPath, pair.search, pair.replace, m.ignoreList, verbose)
if err != nil {
return fmt.Errorf("[branding] [SearchAndRenameFiles] error during execution: %v", err)
}
err = subs.SearchAndRenameDirectories(startPath, pair.search, pair.replace, m.ignoreList, verbose)
if err != nil {
return fmt.Errorf("[branding] [SearchAndRenameDirectories] error during execution: %v", err)
}
}
return nil
}