Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructuring of some command subtrees #1393

Open
wants to merge 112 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
44ceccf
Fix some newlines printed or not
maxlandon Jun 7, 2023
bce0c8d
Add a flags package, in which we store some command utility functions to
maxlandon Jun 7, 2023
ec88f9b
Start splitting commands declarations
maxlandon Jun 7, 2023
f370e96
Finish splitting server commands in their files
maxlandon Jun 20, 2023
e23f040
Split sliver commands in their files
maxlandon Jun 22, 2023
2da61c1
Finish splits. Compiles
maxlandon Jun 22, 2023
51473ec
Add many missing completers
maxlandon Jun 22, 2023
ba34df3
Merge remote-tracking branch 'BishopFox/master' into beacon-commands
maxlandon Jul 19, 2023
c3881b2
Successful use of teamserver/teamclient on first test
maxlandon Jul 19, 2023
9a51d32
New vendor deps + renaming
maxlandon Jul 19, 2023
8cf8e66
A base sliver-server/client compiling with team library
maxlandon Jul 19, 2023
e7b6f5e
The teamserver/teamclient model now works mostly as intended:
maxlandon Jul 20, 2023
2492669
Big refactoring of the client/server console entry/creation code
maxlandon Jul 20, 2023
f3e02c0
Comment server-binary entry and refactor other entries
maxlandon Jul 21, 2023
6e6b774
Comment client entrypoints, remove useless files
maxlandon Jul 21, 2023
1711475
Clean client console a bit
maxlandon Jul 22, 2023
334f8dd
Simplify pre-runners binding
maxlandon Jul 22, 2023
bb59e1e
Add gRPC teamserver/client backend, no code removed yet.
maxlandon Jul 22, 2023
617b5b7
Start removing/cleaning up unused code with teamserver.
maxlandon Jul 23, 2023
139b44d
Keep removing old code not needed
maxlandon Jul 23, 2023
cb8d01e
End of previous commit
maxlandon Jul 23, 2023
e39db64
Remove related operators commands and RPC stub
maxlandon Jul 23, 2023
5583b65
Remove client configs code
maxlandon Jul 23, 2023
d31592b
Go fmt
maxlandon Jul 23, 2023
47a280c
Fix beacon compile flags + debug level for client asciicast
maxlandon Jul 23, 2023
163c11b
Fmt
maxlandon Jul 23, 2023
be65f1c
Filter portfwd/socks commands out of beacons
maxlandon Jul 23, 2023
d5c1daa
Simplify binding commands with groups
maxlandon Jul 23, 2023
fb8e0de
Merge branch 'beacon-commands' into teamclient
maxlandon Jul 23, 2023
af1e52b
Revert "Go fmt"
maxlandon Jul 23, 2023
2ecb88d
Merge back beacon-commands client code
maxlandon Jul 23, 2023
e57f8e8
Simplify binding server-binary-only commands
maxlandon Jul 23, 2023
c9cac60
Add completion for all builder flags
maxlandon Jul 23, 2023
b4f49ca
Update team module dep
maxlandon Jul 23, 2023
0cbdadb
Don't stream client output when completing
maxlandon Jul 24, 2023
cc48d60
Test caching completions. Much better
maxlandon Jul 24, 2023
0c9f918
Fix of all client logstreams, optimized for completion
maxlandon Jul 24, 2023
e3d2026
Find a way more efficient to pre-connect in completions
maxlandon Jul 24, 2023
4fa2c7a
Specify socks/portforwarders IDs as arguments
maxlandon Jul 25, 2023
c793aa5
Fix dymanic sliver target parsing/applying
maxlandon Jul 26, 2023
e0e1992
Cache armory completions to disk
maxlandon Jul 26, 2023
eee1dc2
Simplify sliver implant command tree entry
maxlandon Jul 26, 2023
5d60a3c
Add active target method to filter a command tree
maxlandon Jul 26, 2023
1404c23
Remove dependency buildinfo embeddings
maxlandon Jul 26, 2023
7a2fe67
Add per-implant history stream and commands for query.
maxlandon Jul 27, 2023
c17c6d0
Fix command history not being saved in implant CLI
maxlandon Jul 27, 2023
984b334
Unwrap all gRPC errors returned by calls in commands
maxlandon Jul 27, 2023
8dd3196
Refactor C2 job control command tree & dispatch
maxlandon Jul 27, 2023
1ab9ebb
Add a small cache for Metasploit data:
maxlandon Jul 28, 2023
41fbd48
And deactivate it since we can't really choose payloads
maxlandon Jul 28, 2023
a279ee1
Clean
maxlandon Jul 28, 2023
c535491
Use comp cache duraction groups
maxlandon Jul 28, 2023
63a9edf
Cleanup completion pre-run setup
maxlandon Jul 28, 2023
e795203
Cleanup/rewrite comments for modified transport stack
maxlandon Jul 28, 2023
ecdbf6e
Further cleanup in teamserver transport
maxlandon Jul 28, 2023
1686af1
Fix some log errors
maxlandon Jul 29, 2023
9565314
Cleanup and tidy server transport package.
maxlandon Jul 29, 2023
50d5301
Commit dependencies (useless)
maxlandon Jul 29, 2023
eb127ea
Cleanup and tidy client console/transport code
maxlandon Jul 29, 2023
d5d24e6
Rename a completion pre-runner
maxlandon Jul 29, 2023
15a01fc
Ultimate refactoring/tidying of sliver entrypoints
maxlandon Jul 29, 2023
96585c1
Comment console command yielder
maxlandon Jul 29, 2023
9d76975
Move console connection funcs
maxlandon Jul 29, 2023
6debdb8
Fixes/tweaks to final command output printing
maxlandon Jul 30, 2023
2af630e
Keep tidying
maxlandon Jul 30, 2023
da42eab
Cleanup
maxlandon Jul 30, 2023
27af882
Most of the transition to team/server & team/client is done.
maxlandon Jul 30, 2023
0a22f66
Update teamserver library dependency
maxlandon Jul 30, 2023
a285f40
Switch some commands and completers to multiple args
maxlandon Aug 5, 2023
a995c14
Fixes during presentations
maxlandon Aug 7, 2023
88fc7b6
Update completion engine version
maxlandon Aug 8, 2023
678faac
Cleanups and fixes in command display groups
maxlandon Aug 9, 2023
ed12971
Fixes
maxlandon Aug 10, 2023
87d26f8
Handle blocking operations in CLI
maxlandon Aug 10, 2023
f49fe4b
Move reactions loading to console entry command
maxlandon Aug 10, 2023
2559942
Correctly filter commands even in CLI
maxlandon Aug 10, 2023
0b9cea4
Cleaner interrupts in all menus
maxlandon Aug 10, 2023
0e6c859
Ensure "task sent" is printed before result.
maxlandon Aug 10, 2023
ac04f6d
Fix help completion for implant subtree
maxlandon Aug 10, 2023
83c3565
Fix teamserver not using the db.Client
maxlandon Aug 10, 2023
c7f5f48
Port all beacon commands to Cli usage compatibility
maxlandon Aug 10, 2023
82d0c9c
Update console/completion dependencies
maxlandon Aug 10, 2023
916284c
Fix correct hiding and erroring of unavailable commands
maxlandon Aug 10, 2023
fa61c19
Update deps + few fixes
maxlandon Aug 10, 2023
f256621
Rename flag/comp util functions
maxlandon Aug 10, 2023
16733dd
Update go 1.21
maxlandon Aug 10, 2023
735c233
Update console/readline dependency to latest version.
maxlandon Aug 17, 2023
41aa386
Update following dependencies
maxlandon Aug 17, 2023
3355627
Mostly display fixes and enhancements
maxlandon Aug 17, 2023
3415cce
Fixes to logging
maxlandon Aug 17, 2023
c0810ee
Update team dependency with first release
maxlandon Aug 17, 2023
90760ec
Update vendor dependencies
maxlandon Aug 17, 2023
3d2a337
Rename/cleanup command utility binders/generators
maxlandon Aug 18, 2023
fad8d23
Split/restructure console code into files, check comments everywhere
maxlandon Aug 18, 2023
64628c5
Comment remaining client code
maxlandon Aug 18, 2023
8040e5f
Cleanup, slicker API, fixes and optimizations
maxlandon Aug 18, 2023
6e685e9
Rename some function better, update dependencies with fix.
maxlandon Aug 18, 2023
efb1b6d
Finish builder client port to teamclient
maxlandon Aug 18, 2023
532bfaf
Test and fix builders with a simple teamclient backend.
maxlandon Aug 18, 2023
8b56c5b
Fix mistake, fortunately
maxlandon Aug 18, 2023
7ae0eee
Remove most calls to panic in client (where possible and safe)
maxlandon Aug 18, 2023
67a6e3b
Fixes
maxlandon Aug 18, 2023
ab0755b
Implement task-canceled for clients to unblock
maxlandon Aug 18, 2023
c4dd651
Better wrapping for all tables
maxlandon Aug 18, 2023
06005d9
Fix stupid Tailscale compilation issue and keep last commits' work
maxlandon Aug 19, 2023
85cf086
Update console dependency with fixes
maxlandon Aug 19, 2023
84779ea
Hide some commands in CLI
maxlandon Aug 26, 2023
a9f47db
Merge remote-tracking branch 'BishopFox/master' into teamclient
maxlandon Aug 26, 2023
ec6c545
fix kill for sessions
rkervella Aug 8, 2023
89cc659
Fix status when killing session
maxlandon Aug 26, 2023
0f27771
Don't add version to offline commands
maxlandon Aug 26, 2023
a7f56eb
Command tree refactoring for some stuff
maxlandon Aug 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test and fix builders with a simple teamclient backend.
  • Loading branch information
maxlandon committed Aug 18, 2023
commit 532bfaf43d9c5dd5f42b37e164410c35290defde
9 changes: 6 additions & 3 deletions client/console/console.go
Original file line number Diff line number Diff line change
@@ -105,8 +105,11 @@ type SliverClient struct {
isCLI bool

// Teamclient & remotes
// The dialer being exported is quite dirty,
// and there might be a way to unexport it.
// The problem is currently with builders which need it.
Teamclient *client.Client
dialer *transport.TeamClient
Dialer *transport.TeamClient
preRunners []func(*cobra.Command, []string) error

// Logging
@@ -148,12 +151,12 @@ func NewSliverClient(opts ...grpc.DialOption) (con *SliverClient, err error) {
con = newClient()

// Our reeflective/team.Client needs our gRPC stack.
con.dialer = transport.NewClient(opts...)
con.Dialer = transport.NewClient(opts...)

var clientOpts []client.Options
clientOpts = append(clientOpts,
client.WithHomeDirectory(assets.GetRootAppDir()),
client.WithDialer(con.dialer),
client.WithDialer(con.Dialer),
client.WithLogger(initTeamclientLog()),
)

4 changes: 2 additions & 2 deletions client/console/teamclient.go
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ func (con *SliverClient) PreRunConnect(cmd *cobra.Command, args []string) error

// Register our Sliver client services, and monitor events.
// Also set ourselves up to save our client commands in history.
con.connect(con.dialer.Conn)
con.connect(con.Dialer.Conn)

// Never enable asciicasts/logs streaming when this
// client is used to perform completions. Both of these will tinker
@@ -114,7 +114,7 @@ func (con *SliverClient) PreRunComplete() (carapace.Action, error) {

// Register our Sliver client services, and monitor events.
// Also set ourselves up to save our client commands in history.
con.connect(con.dialer.Conn)
con.connect(con.Dialer.Conn)

return carapace.ActionValues(), nil
}
6 changes: 3 additions & 3 deletions server/builder/builder.go
Original file line number Diff line number Diff line change
@@ -46,11 +46,11 @@ type Config struct {
}

// StartBuilder - main entry point for the builder
func StartBuilder(externalBuilder *clientpb.Builder, con *console.SliverClient) error {
func StartBuilder(externalBuilder *clientpb.Builder, rpc rpcpb.SliverRPCClient, con *console.SliverClient) error {
builderLog.Infof("Attempting to register builder: %s", externalBuilder.Name)
con.PrintInfof("Attempting to register builder: %s", externalBuilder.Name)

events, err := buildEvents(externalBuilder, con.Rpc)
events, err := buildEvents(externalBuilder, rpc)
if err != nil {
builderLog.Errorf("Build events handler error: %s", err.Error())
return nil
@@ -59,7 +59,7 @@ func StartBuilder(externalBuilder *clientpb.Builder, con *console.SliverClient)
// Wait for signal or builds
go func() {
for event := range events {
go handleBuildEvent(externalBuilder, event, con.Rpc)
go handleBuildEvent(externalBuilder, event, rpc)
}
}()

3 changes: 2 additions & 1 deletion server/command/assets/unpack.go
Original file line number Diff line number Diff line change
@@ -21,9 +21,10 @@ package assets
import (
"fmt"

"github.com/spf13/cobra"

"github.com/bishopfox/sliver/server/assets"
"github.com/bishopfox/sliver/server/msf"
"github.com/spf13/cobra"
)

const (
30 changes: 17 additions & 13 deletions server/command/builder/builder.go
Original file line number Diff line number Diff line change
@@ -34,8 +34,10 @@ import (

"github.com/bishopfox/sliver/client/command/completers"
"github.com/bishopfox/sliver/client/console"
"github.com/bishopfox/sliver/client/transport"
"github.com/bishopfox/sliver/client/version"
"github.com/bishopfox/sliver/protobuf/clientpb"
"github.com/bishopfox/sliver/protobuf/rpcpb"
"github.com/bishopfox/sliver/server/builder"
"github.com/bishopfox/sliver/server/generate"
"github.com/bishopfox/sliver/server/log"
@@ -61,7 +63,7 @@ func Commands(con *console.SliverClient, team *server.Server) []*cobra.Command {
Short: "Start the process as an external builder",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
runBuilderCmd(cmd, args, team)
runBuilderCmd(cmd, args, team, con)
},
}

@@ -83,7 +85,7 @@ func Commands(con *console.SliverClient, team *server.Server) []*cobra.Command {
return []*cobra.Command{builderCmd}
}

func runBuilderCmd(cmd *cobra.Command, args []string, team *server.Server) error {
func runBuilderCmd(cmd *cobra.Command, args []string, team *server.Server, con *console.SliverClient) error {
configPath, err := cmd.Flags().GetString(operatorConfigFlagStr)
if err != nil {
builderLog.Errorf("Failed to parse --%s flag %s\n", operatorConfigFlagStr, err)
@@ -122,7 +124,7 @@ func runBuilderCmd(cmd *cobra.Command, args []string, team *server.Server) error
externalBuilder.Templates = []string{"sliver"}

// load the client configuration from the filesystem
return startBuilderTeamclient(externalBuilder, configPath, team)
return startBuilderClient(externalBuilder, configPath, team, con)
}

func parseBuilderConfigFlags(cmd *cobra.Command) *clientpb.Builder {
@@ -255,14 +257,11 @@ func parseForceDisableTargets(cmd *cobra.Command, externalBuilder *clientpb.Buil
}
}

func startBuilderTeamclient(externalBuilder *clientpb.Builder, configPath string, team *server.Server) error {
// Make an altogether new Sliver client. We have all of its tooling by default, at no cost.
sliverClient, err := console.NewSliverClient()
if err != nil {
return err
}
func startBuilderClient(externalBuilder *clientpb.Builder, configPath string, team *server.Server, con *console.SliverClient) error {
// Simply use our transport+RPC backend.
cli := transport.NewClient()

teamclient := sliverClient.Teamclient
teamclient := team.Self(client.WithDialer(cli))

// Now use our teamclient to fetch the configuration.
config, err := teamclient.ReadConfig(configPath)
@@ -282,14 +281,19 @@ func startBuilderTeamclient(externalBuilder *clientpb.Builder, configPath string
builderLog.Infof("Hello my name is: %s", externalBuilder.Name)

builderLog.Infof("Connecting to %s@%s:%d ...", config.User, config.Host, config.Port)
sliverClient.PrintInfof("Connecting to %s@%s:%d ...", config.User, config.Host, config.Port)

// And immediately connect to it.
teamclient.Connect(client.WithConfig(config))
err = teamclient.Connect(client.WithConfig(config))
if err != nil {
return err
}

rpc := rpcpb.NewSliverRPCClient(cli.Conn)

defer teamclient.Disconnect()

// Let the builder do its work, blocking.
return builder.StartBuilder(externalBuilder, sliverClient)
return builder.StartBuilder(externalBuilder, rpc, con)
}

// builderFormatsCompleter completes supported builders architectures.