Skip to content

Commit

Permalink
Fix all merge stuff, compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlandon committed Nov 28, 2023
1 parent 08bf40b commit 08d26e9
Show file tree
Hide file tree
Showing 313 changed files with 15,717 additions and 9,094 deletions.
6 changes: 3 additions & 3 deletions client/command/c2profiles/c2profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
)

// C2ProfileCmd list available http profiles
func C2ProfileCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {
func C2ProfileCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
profileName, _ := cmd.Flags().GetString("name")

if profileName == constants.DefaultC2Profile {
Expand All @@ -61,7 +61,7 @@ func C2ProfileCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []s
PrintC2Profiles(profile, con)
}

func ImportC2ProfileCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {
func ImportC2ProfileCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
protocols := []string{constants.HttpStr, constants.HttpsStr}
profileName, _ := cmd.Flags().GetString("name")
if profileName == "" {
Expand Down Expand Up @@ -248,7 +248,7 @@ func C2ConfigToProtobuf(profileName string, config *assets.HTTPC2Config) *client
}

// PrintImplantBuilds - Print the implant builds on the server
func PrintC2Profiles(profile *clientpb.HTTPC2Config, con *console.SliverConsoleClient) {
func PrintC2Profiles(profile *clientpb.HTTPC2Config, con *console.SliverClient) {

tw := table.NewWriter()
tw.SetStyle(settings.GetTableStyle(con))
Expand Down
13 changes: 6 additions & 7 deletions client/command/filesystem/grep.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func processFlags(searchPattern string, insensitive bool, exact bool) string {
return searchPattern
}

var processedSearchPattern = searchPattern
processedSearchPattern := searchPattern

flagsAtBeginning, _ := regexp.Compile(`^\(\?.*\)`)
flagsSpecifiedIndex := flagsAtBeginning.FindStringIndex(searchPattern)
Expand All @@ -62,7 +62,7 @@ func processFlags(searchPattern string, insensitive bool, exact bool) string {
flagsSpecifiedIndex = flagsAtBeginning.FindStringIndex(processedSearchPattern)

if exact {
var endIndexOfFlags = 0
endIndexOfFlags := 0

if flagsSpecifiedIndex != nil {
endIndexOfFlags = flagsSpecifiedIndex[1]
Expand All @@ -83,7 +83,7 @@ func processFlags(searchPattern string, insensitive bool, exact bool) string {
return processedSearchPattern
}

func GrepCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {
func GrepCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
session, beacon := con.ActiveTarget.GetInteractive()
if session == nil && beacon == nil {
return
Expand Down Expand Up @@ -136,7 +136,7 @@ func GrepCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string
return
}
if grep.Response != nil && grep.Response.Async {
con.AddBeaconCallback(grep.Response.TaskID, func(task *clientpb.BeaconTask) {
con.AddBeaconCallback(grep.Response, func(task *clientpb.BeaconTask) {
err = proto.Unmarshal(task.Response, grep)
if err != nil {
con.PrintErrorf("Failed to decode response %s\n", err)
Expand All @@ -152,7 +152,7 @@ func GrepCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string
}

// printGrep - Print the results from the grep operation to stdout
func printGrep(grep *sliverpb.Grep, searchPattern string, searchPath string, cmd *cobra.Command, con *console.SliverConsoleClient) {
func printGrep(grep *sliverpb.Grep, searchPattern string, searchPath string, cmd *cobra.Command, con *console.SliverClient) {
saveLoot, _ := cmd.Flags().GetBool("loot")
lootName, _ := cmd.Flags().GetString("name")
colorize, _ := cmd.Flags().GetBool("colorize-output")
Expand Down Expand Up @@ -233,7 +233,6 @@ func printGrep(grep *sliverpb.Grep, searchPattern string, searchPath string, cmd
fileType := loot.ValidateLootFileType(userLootFileType, []byte(grepResultsString))
loot.LootText(grepResultsString, lootName, lootFileName, fileType, con)
}

}

// grepLineResult - Add color or formatting for results for console output
Expand Down Expand Up @@ -268,7 +267,7 @@ func grepLineResult(positions []*sliverpb.GrepLinePosition, line string, coloriz
// printGrepResults - Take the results from the implant and put them together for output to the console or loot
func printGrepResults(results map[string]*sliverpb.GrepResultsForFile, colorize bool, allowFormatting bool) ([]string, int, []string) {
var resultOutput []string
var numberOfResults = 0
numberOfResults := 0
binaryFilesMatched := []string{}

for fileName, result := range results {
Expand Down
4 changes: 2 additions & 2 deletions client/command/filesystem/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"google.golang.org/protobuf/proto"
)

func HeadCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string, head bool) {
func HeadCmd(cmd *cobra.Command, con *console.SliverClient, args []string, head bool) {
session, beacon := con.ActiveTarget.GetInteractive()
if session == nil && beacon == nil {
return
Expand Down Expand Up @@ -112,7 +112,7 @@ func HeadCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string
return
}
if download.Response != nil && download.Response.Async {
con.AddBeaconCallback(download.Response.TaskID, func(task *clientpb.BeaconTask) {
con.AddBeaconCallback(download.Response, func(task *clientpb.BeaconTask) {
err = proto.Unmarshal(task.Response, download)
if err != nil {
con.PrintErrorf("Failed to decode response %s\n", err)
Expand Down
4 changes: 2 additions & 2 deletions client/command/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func nameOfOutputFormat(value clientpb.OutputFormat) string {
}

// Shared function that extracts the compile flags from the grumble context.
func parseCompileFlags(cmd *cobra.Command, con *console.SliverClient) *clientpb.ImplantConfig {
func parseCompileFlags(cmd *cobra.Command, con *console.SliverClient) (string, *clientpb.ImplantConfig) {
var name string
if nameF, _ := cmd.Flags().GetString("name"); nameF != "" {
name = strings.ToLower(nameF)
Expand Down Expand Up @@ -783,7 +783,7 @@ func ParseTCPPivotc2(args string) ([]*clientpb.ImplantC2, error) {
return c2s, nil
}

func externalBuild(config *clientpb.ImplantConfig, save string, con *console.SliverClient) (*commonpb.File, error) {
func externalBuild(name string, config *clientpb.ImplantConfig, save string, con *console.SliverClient) (*commonpb.File, error) {
potentialBuilders, err := findExternalBuilders(config, con)
if err != nil {
return nil, err
Expand Down
50 changes: 11 additions & 39 deletions client/command/generate/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/bishopfox/sliver/protobuf/commonpb"
)

// GetSliverBinary - Get the binary of an implant based on it's profile.
// GetSliverBinary - Get the binary of an implant based on it's profile
func GetSliverBinary(profile *clientpb.ImplantProfile, con *console.SliverClient) ([]byte, error) {
var data []byte

Expand All @@ -28,43 +28,14 @@ func GetSliverBinary(profile *clientpb.ImplantProfile, con *console.SliverClient
ctrl <- true
<-ctrl
if err != nil {
return data, con.UnwrapServerErr(err)
con.PrintErrorf("Error generating implant\n")
return data, err
}

implantName := buildImplantName(profile.GetConfig().GetFileName())
_, ok := builds.GetConfigs()[implantName]
if implantName == "" || !ok {
// no built implant found for profile, generate a new one
con.PrintInfof("No builds found for profile %s, generating a new one\n", profile.GetName())
ctrl := make(chan bool)
con.SpinUntil("Compiling, please wait ...", ctrl)

generated, err := con.Rpc.Generate(context.Background(), &clientpb.GenerateReq{
Config: profile.Config,
})
ctrl <- true
<-ctrl
if err != nil {
con.PrintErrorf("Error generating implant\n")
return data, con.UnwrapServerErr(err)
}
data = generated.GetFile().GetData()
profile.Config.FileName = generated.File.Name
_, err = con.Rpc.SaveImplantProfile(context.Background(), profile)
if err != nil {
con.PrintErrorf("Error updating implant profile\n")
return data, con.UnwrapServerErr(err)
}
} else {
// Found a build, reuse that one
con.PrintInfof("Sliver name for profile: %s\n", implantName)
regenerate, err := con.Rpc.Regenerate(context.Background(), &clientpb.RegenerateReq{
ImplantName: implantName,
})
if err != nil {
return data, con.UnwrapServerErr(err)
}
data = regenerate.GetFile().GetData()
data = generated.GetFile().GetData()
_, err = con.Rpc.SaveImplantProfile(context.Background(), profile)
if err != nil {
con.PrintErrorf("Error updating implant profile\n")
return data, err
}
return data, err
}
Expand Down Expand Up @@ -185,11 +156,12 @@ func TrafficEncodersCompleter(con *console.SliverClient) carapace.Action {
}

// HTTPC2Completer - Completes the HTTP C2 PROFILES
func HTTPC2Completer(con *console.SliverConsoleClient) carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
func HTTPC2Completer(con *console.SliverClient) carapace.Action {
return carapace.ActionCallback(func(_ carapace.Context) carapace.Action {
if msg, err := con.PreRunComplete(); err != nil {
return msg
}

grpcCtx, cancel := con.GrpcContext(nil)
defer cancel()
httpC2Profiles, err := con.Rpc.GetHTTPC2Profiles(grpcCtx, &commonpb.Empty{})
Expand Down
4 changes: 2 additions & 2 deletions client/command/generate/implants-stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
)

// ImplantsStageCmd - Serve a previously generated build
func ImplantsStageCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {
func ImplantsStageCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
builds, err := con.Rpc.ImplantBuilds(context.Background(), &commonpb.Empty{})
if err != nil {
con.PrintErrorf("Unable to load implant builds '%s'\n", err)
return
}

options := []string{}
for name, _ := range builds.Configs {
for name := range builds.Configs {
options = append(options, name)
}

Expand Down
2 changes: 1 addition & 1 deletion client/command/generate/profiles-stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

// ProfilesStageCmd - Generate an encrypted/compressed implant binary based on a profile
func ProfilesStageCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {
func ProfilesStageCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
name, _ := cmd.Flags().GetString("name")
profileName := args[0]
aesEncryptKey, _ := cmd.Flags().GetString("aes-encrypt-key")
Expand Down
2 changes: 1 addition & 1 deletion client/command/help/long-help.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ Sliver uses the same hash identifiers as Hashcat (use the #):
% 10s - One hash per line.
% 10s - A file containing lines of 'username:hash' pairs.
% 10s - A CSV file containing 'username,hash' pairs (additional columns ignored).
`, creds.HashNewlineFormat, creds.UserColonHashNewlineFormat, creds.CSVFormat)
`, consts.HashNewlineFormat, consts.UserColonHashNewlineFormat, consts.CSVFormat)

c2ProfilesHelp = `[[.Bold]]Command:[[.Normal]] c2profile
[[.Bold]]About:[[.Normal]] Display details of HTTP C2 profiles loaded into Sliver.
Expand Down
12 changes: 4 additions & 8 deletions client/command/monitor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import (
"github.com/spf13/cobra"
)

func MonitorConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {

func MonitorConfigCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
resp, err := con.Rpc.MonitorListConfig(context.Background(), &commonpb.Empty{})
if err != nil {
con.PrintErrorf("%s\n", err)
Expand All @@ -41,8 +40,7 @@ func MonitorConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
PrintWTConfig(resp, con)
}

func MonitorAddConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {

func MonitorAddConfigCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
apiKey, _ := cmd.Flags().GetString("apiKey")
apiPassword, _ := cmd.Flags().GetString("apiPassword")
apiType, _ := cmd.Flags().GetString("type")
Expand All @@ -65,8 +63,7 @@ func MonitorAddConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, a
con.PrintInfof("Added monitoring configuration\n")
}

func MonitorDelConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args []string) {

func MonitorDelConfigCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
resp, err := con.Rpc.MonitorListConfig(context.Background(), &commonpb.Empty{})
if err != nil {
con.PrintErrorf("%s\n", err)
Expand All @@ -88,7 +85,7 @@ func MonitorDelConfigCmd(cmd *cobra.Command, con *console.SliverConsoleClient, a
}

// PrintWTConfig - Print the current watchtower configuration
func PrintWTConfig(configs *clientpb.MonitoringProviders, con *console.SliverConsoleClient) {
func PrintWTConfig(configs *clientpb.MonitoringProviders, con *console.SliverClient) {
tw := table.NewWriter()
tw.SetStyle(settings.GetTableStyle(con))

Expand All @@ -114,7 +111,6 @@ func PrintWTConfig(configs *clientpb.MonitoringProviders, con *console.SliverCon
}

func selectWatchtowerConfig(configs *clientpb.MonitoringProviders) (*clientpb.MonitoringProvider, error) {

var options []string
for _, config := range configs.Providers {
options = append(options, config.Type)
Expand Down
2 changes: 1 addition & 1 deletion client/console/implant.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (con *SliverClient) GetActiveSessionConfig() *clientpb.ImplantConfig {
Priority: uint32(0),
})
config := &clientpb.ImplantConfig{
Name: session.GetName(),
ID: session.ID,
GOOS: session.GetOS(),
GOARCH: session.GetArch(),
Debug: true,
Expand Down
36 changes: 15 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ go 1.21.1

toolchain go1.21.4

// A fork of the completion engine is currently used in order to consume the engine
// as a library. The fork is a very slightly patched mainline tree for that purpose,
// and is regularly maintained up-to-date with upstream. Should be removed long-term.
//
// To update or try to:
// - You must replace rsteube/carapace v0.43.0 with the version found in the main require.
// - You must replace v0.25.2... with "library", then go mod tidy && go mod vendor.
replace github.com/rsteube/carapace v0.43.0 => github.com/reeflective/carapace v0.25.2-0.20230816093630-a30f5184fa0d
replace github.com/rsteube/carapace v0.45.0 => github.com/reeflective/carapace v0.25.2-0.20230602202234-e8d757e458ca

require (
filippo.io/age v1.1.1
Expand Down Expand Up @@ -41,23 +34,24 @@ require (
github.com/miekg/dns v1.1.57
github.com/moloch--/asciicast v0.1.0
github.com/moloch--/memmod v0.0.0-20211120144554-8b37cc654945
github.com/ncruces/go-sqlite3 v0.7.2
github.com/reeflective/console v0.1.6
github.com/ncruces/go-sqlite3 v0.8.4
github.com/reeflective/console v0.1.11
github.com/reeflective/readline v1.0.11
github.com/rsteube/carapace v0.36.3
github.com/reeflective/team v0.1.1
github.com/rsteube/carapace v0.45.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/tetratelabs/wazero v1.3.1
github.com/tetratelabs/wazero v1.4.0
github.com/things-go/go-socks5 v0.0.3
github.com/xlab/treeprint v1.2.0
github.com/yiya1989/sshkrb5 v0.0.1
golang.org/x/crypto v0.15.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/net v0.17.0
golang.org/x/sys v0.14.0
golang.org/x/term v0.14.0
golang.org/x/crypto v0.16.0
golang.org/x/exp v0.0.0-20231127185646-65229373498e
golang.org/x/net v0.19.0
golang.org/x/sys v0.15.0
golang.org/x/term v0.15.0
golang.org/x/text v0.14.0
golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220208144051-fde48d68ee68
Expand Down Expand Up @@ -138,7 +132,6 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.1-0.20230202152459-5c7d0dd6ab86 // indirect
github.com/jsimonetti/rtnetlink v1.3.5 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand Down Expand Up @@ -176,10 +169,10 @@ require (
github.com/x448/float16 v0.8.4 // indirect
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
go4.org/netipx v0.0.0-20230824141953-6213f710f925 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
Expand All @@ -199,5 +192,6 @@ require (
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.0.1 // indirect
mvdan.cc/sh/v3 v3.7.0 // indirect
nhooyr.io/websocket v1.8.7 // indirect
)
Loading

0 comments on commit 08d26e9

Please sign in to comment.