Skip to content

Commit

Permalink
Merge pull request #1457 from BishopFox/allow_selective_staging
Browse files Browse the repository at this point in the history
Allow selective staging
  • Loading branch information
moloch-- authored Nov 14, 2023
2 parents 5d333af + 6918743 commit 632eacf
Show file tree
Hide file tree
Showing 21 changed files with 3,841 additions and 3,602 deletions.
39 changes: 39 additions & 0 deletions client/command/generate/implants-stage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package generate

import (
"context"

"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra"

"github.com/bishopfox/sliver/client/console"
"github.com/bishopfox/sliver/protobuf/clientpb"
"github.com/bishopfox/sliver/protobuf/commonpb"
)

// ImplantsStageCmd - Serve a previously generated build
func ImplantsStageCmd(cmd *cobra.Command, con *console.SliverConsoleClient, 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 {
options = append(options, name)
}

prompt := &survey.MultiSelect{
Message: "Select sessions and beacons to expose:",
Options: options,
}
selected := []string{}
survey.AskOne(prompt, &selected)

_, err = con.Rpc.StageImplantBuild(context.Background(), &clientpb.ImplantStageReq{Build: selected})
if err != nil {
con.PrintErrorf("Failed to serve implant %s\n", err)
return
}
}
2 changes: 2 additions & 0 deletions client/command/generate/implants.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func PrintImplantBuilds(builds *clientpb.ImplantBuilds, filters ImplantBuildFilt
"Debug",
"C2 Config",
"ID",
"Stage",
})
tw.SortBy([]table.SortBy{
{Name: "Name", Mode: table.Asc},
Expand Down Expand Up @@ -126,6 +127,7 @@ func PrintImplantBuilds(builds *clientpb.ImplantBuilds, filters ImplantBuildFilt
fmt.Sprintf("%v", config.Debug),
fmt.Sprintf(config.HTTPC2ConfigName),
fmt.Sprintf("%v", builds.ResourceIDs[sliverName].Value),
fmt.Sprintf("%v", builds.Staged[sliverName]),
})
}

Expand Down
2 changes: 0 additions & 2 deletions client/command/jobs/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func HTTPListenerCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
pollTimeout, _ := cmd.Flags().GetString("long-poll-timeout")
pollJitter, _ := cmd.Flags().GetString("long-poll-jitter")
website, _ := cmd.Flags().GetString("website")
staging, _ := cmd.Flags().GetBool("staging")

longPollTimeout, err := time.ParseDuration(pollTimeout)
if err != nil {
Expand All @@ -60,7 +59,6 @@ func HTTPListenerCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
EnforceOTP: !disableOTP,
LongPollTimeout: int64(longPollTimeout),
LongPollJitter: int64(longPollJitter),
Staging: staging,
})
if err != nil {
con.PrintErrorf("%s\n", err)
Expand Down
2 changes: 0 additions & 2 deletions client/command/jobs/https.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func HTTPSListenerCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
website, _ := cmd.Flags().GetString("website")
letsEncrypt, _ := cmd.Flags().GetBool("lets-encrypt")
disableRandomize, _ := cmd.Flags().GetBool("disable-randomized-jarm")
staging, _ := cmd.Flags().GetBool("staging")

longPollTimeout, err := time.ParseDuration(pollTimeout)
if err != nil {
Expand Down Expand Up @@ -76,7 +75,6 @@ func HTTPSListenerCmd(cmd *cobra.Command, con *console.SliverConsoleClient, args
LongPollTimeout: int64(longPollTimeout),
LongPollJitter: int64(longPollJitter),
RandomizeJARM: !disableRandomize,
Staging: staging,
})
con.Println()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions client/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,16 @@ func ServerCommands(con *client.SliverConsoleClient, serverCmds func() []*cobra.
carapace.Gen(implantsRmCmd).PositionalCompletion(generate.ImplantBuildNameCompleter(con))
implantBuildsCmd.AddCommand(implantsRmCmd)

implantStageCmd := &cobra.Command{
Use: consts.StageStr,
Short: "Serve a previously generated implant",
Long: help.GetHelpFor([]string{consts.ImplantBuildsStr, consts.StageStr}),
Run: func(cmd *cobra.Command, args []string) {
generate.ImplantsStageCmd(cmd, con, args)
},
}
implantBuildsCmd.AddCommand(implantStageCmd)

canariesCmd := &cobra.Command{
Use: consts.CanariesStr,
Short: "List previously generated canaries",
Expand Down
Loading

0 comments on commit 632eacf

Please sign in to comment.