console

package
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: GPL-3.0 Imports: 36 Imported by: 50

README

client/console

Overview

Renders the interactive console UI, logging, and terminal helpers for the client. Coordinates readline behavior, prompt styling, and message formatting.

Go Files

  • console.go – Implements the interactive console, prompt rendering, and RPC client integration.
  • log.go – Provides structured logging utilities and output filters tailored to the console experience.

Documentation

Index

Constants

View Source
const (
	// Terminal control sequences (not "styling").
	Clearln = "\r\x1b[2K"
	UpN     = "\033[%dA"
	DownN   = "\033[%dB"
)

Variables

View Source
var (
	StyleNormal    = lipgloss.NewStyle()
	StyleBold      = lipgloss.NewStyle().Bold(true)
	StyleUnderline = lipgloss.NewStyle().Underline(true)

	// Theme palette styles.
	StylePrimary   = lipgloss.NewStyle()
	StyleSecondary = lipgloss.NewStyle()
	StyleDefault   = lipgloss.NewStyle()
	StyleSuccess   = lipgloss.NewStyle()
	StyleWarning   = lipgloss.NewStyle()
	StyleDanger    = lipgloss.NewStyle()

	StyleBoldPrimary   = lipgloss.NewStyle()
	StyleBoldSecondary = lipgloss.NewStyle()
	StyleBoldDefault   = lipgloss.NewStyle()
	StyleBoldSuccess   = lipgloss.NewStyle()
	StyleBoldWarning   = lipgloss.NewStyle()
	StyleBoldDanger    = lipgloss.NewStyle()

	// Legacy color names used across the codebase.
	StyleBlack  = lipgloss.NewStyle()
	StyleRed    = lipgloss.NewStyle()
	StyleGreen  = lipgloss.NewStyle()
	StyleOrange = lipgloss.NewStyle()
	StyleBlue   = lipgloss.NewStyle()
	StylePurple = lipgloss.NewStyle()
	StyleCyan   = lipgloss.NewStyle()
	StyleGray   = lipgloss.NewStyle()

	StyleBoldBlack  = lipgloss.NewStyle()
	StyleBoldRed    = lipgloss.NewStyle()
	StyleBoldGreen  = lipgloss.NewStyle()
	StyleBoldOrange = lipgloss.NewStyle()
	StyleBoldBlue   = lipgloss.NewStyle()
	StyleBoldPurple = lipgloss.NewStyle()
	StyleBoldCyan   = lipgloss.NewStyle()
	StyleBoldGray   = lipgloss.NewStyle()
)
View Source
var (
	Info    string
	Warn    string
	Debug   string
	Woot    string
	Success string
)

Prefix tags used across the client/server consoles.

Functions

func ApplyTheme added in v1.7.1

func ApplyTheme(t theme.Theme)

ApplyTheme updates all exported styles/prefixes to match the provided theme.

Note: this is intentionally a "global theme" for the console, since most of the existing code expects these styles to be package-level values.

func StartClient added in v1.6.0

func StartClient(con *SliverClient, rpc rpcpb.SliverRPCClient, grpcConn *grpc.ClientConn, details *ConnectionDetails, serverCmds, sliverCmds console.Commands, run bool, rcScript string) error

Init requires a working RPC connection to the sliver server, and 2 different sets of commands. If run is true, the console application is started, making this call blocking. Otherwise, commands and RPC connection are bound to the console (making the console ready to run), but the console does not start.

Types

type ActiveTarget added in v1.5.0

type ActiveTarget struct {
	// contains filtered or unexported fields
}

func (*ActiveTarget) AddObserver added in v1.5.0

func (s *ActiveTarget) AddObserver(observer Observer) int

AddObserver - Observers to notify when the active session changes

func (*ActiveTarget) Background added in v1.5.0

func (s *ActiveTarget) Background()

Background - Background the active session.

func (*ActiveTarget) Get added in v1.5.0

GetSessionInteractive - Get the active target(s).

func (*ActiveTarget) GetBeacon added in v1.5.0

func (s *ActiveTarget) GetBeacon() *clientpb.Beacon

GetBeacon - Same as GetBeacon() but doesn't print a warning.

func (*ActiveTarget) GetBeaconInteractive added in v1.5.0

func (s *ActiveTarget) GetBeaconInteractive() *clientpb.Beacon

GetBeaconInteractive - Get beacon interactive the active session.

func (*ActiveTarget) GetHostUUID added in v1.6.0

func (s *ActiveTarget) GetHostUUID() string

GetHostUUID - Get the Host's UUID (ID in the database)

func (*ActiveTarget) GetInteractive added in v1.5.0

func (s *ActiveTarget) GetInteractive() (*clientpb.Session, *clientpb.Beacon)

GetSessionInteractive - Get the active target(s).

func (*ActiveTarget) GetSession added in v1.5.0

func (s *ActiveTarget) GetSession() *clientpb.Session

GetSession - Same as GetSession() but doesn't print a warning.

func (*ActiveTarget) GetSessionInteractive added in v1.5.0

func (s *ActiveTarget) GetSessionInteractive() *clientpb.Session

GetSessionInteractive - GetSessionInteractive the active session.

func (*ActiveTarget) IsBeacon added in v1.6.0

func (s *ActiveTarget) IsBeacon() bool

IsBeacon - Is the current target a beacon?

func (*ActiveTarget) IsSession added in v1.5.0

func (s *ActiveTarget) IsSession() bool

IsSession - Is the current target a session?

func (*ActiveTarget) RemoveObserver added in v1.5.0

func (s *ActiveTarget) RemoveObserver(observerID int)

func (*ActiveTarget) Request added in v1.5.0

func (s *ActiveTarget) Request(cmd *cobra.Command) *commonpb.Request

func (*ActiveTarget) Set added in v1.5.0

func (s *ActiveTarget) Set(session *clientpb.Session, beacon *clientpb.Beacon)

Set - Change the active session.

type BeaconTaskCallback added in v1.5.0

type BeaconTaskCallback func(*clientpb.BeaconTask)

Observer - A function to call when the sessions changes.

type ConnectionDetails added in v1.7.1

type ConnectionDetails struct {
	ConfigKey string
	Config    *assets.ClientConfig
}

ConnectionDetails provides (optional) metadata about the active connection. In the sliver-client binary this is typically sourced from ~/.sliver-client/configs/*.

type ConsoleClientLogger added in v1.6.0

type ConsoleClientLogger struct {
	Stream rpcpb.SliverRPC_ClientLogClient
	// contains filtered or unexported fields
}

ConsoleClientLogger is an io.Writer that sends data to the server.

func (*ConsoleClientLogger) Write added in v1.6.0

func (l *ConsoleClientLogger) Write(buf []byte) (int, error)

type Observer added in v1.4.18

type Observer func(*clientpb.Session, *clientpb.Beacon)

Observer - A function to call when the sessions changes.

type SliverClient added in v1.6.0

type SliverClient struct {
	App                      *console.Console
	Rpc                      rpcpb.SliverRPCClient
	ActiveTarget             *ActiveTarget
	EventListeners           *sync.Map
	BeaconTaskCallbacks      map[string]BeaconTaskCallback
	BeaconTaskCallbacksMutex *sync.Mutex
	Settings                 *assets.ClientSettings
	IsServer                 bool
	IsCLI                    bool
	// contains filtered or unexported fields
}

func NewConsole added in v1.6.0

func NewConsole(isServer bool) *SliverClient

NewConsole creates the sliver client (and console), creating menus and prompts. The returned console does neither have commands nor a working RPC connection yet, thus has not started monitoring any server events, or started the application.

func (*SliverClient) AddBeaconCallback added in v1.6.0

func (con *SliverClient) AddBeaconCallback(taskID string, callback BeaconTaskCallback)

func (*SliverClient) CheckLastUpdate added in v1.6.0

func (con *SliverClient) CheckLastUpdate()

func (*SliverClient) ClientLogStream added in v1.6.0

func (con *SliverClient) ClientLogStream(name string) (*ConsoleClientLogger, error)

ClientLogStream requires a log stream name, used to save the logs going through this stream in a specific log subdirectory/file.

func (*SliverClient) CloseConnection added in v1.7.1

func (con *SliverClient) CloseConnection() error

CloseConnection stops background loops and closes the current gRPC connection.

func (*SliverClient) CreateEventListener added in v1.6.0

func (con *SliverClient) CreateEventListener() (string, <-chan *clientpb.Event)

CreateEventListener - creates a new event listener and returns its ID.

func (*SliverClient) CurrentConnection added in v1.7.1

func (con *SliverClient) CurrentConnection() (*ConnectionDetails, connectivity.State, bool)

CurrentConnection returns the current connection metadata, if any.

func (*SliverClient) ExposeCommands added in v1.6.0

func (con *SliverClient) ExposeCommands()

Expose or hide commands if the active target does support them (or not). Ex; hide Windows commands on Linux implants, Wireguard tools on HTTP C2, etc.

func (*SliverClient) FlushOutput added in v1.6.2

func (con *SliverClient) FlushOutput()

FlushOutput drains any piped stdout before exiting.

func (*SliverClient) FormatDateDelta added in v1.6.0

func (con *SliverClient) FormatDateDelta(t time.Time, includeDate bool, color bool) string

FormatDateDelta - Generate formatted date string of the time delta between then and now.

func (*SliverClient) GetActiveBeaconConfig added in v1.6.0

func (con *SliverClient) GetActiveBeaconConfig() *clientpb.ImplantConfig

func (*SliverClient) GetActiveSessionConfig added in v1.6.0

func (con *SliverClient) GetActiveSessionConfig() *clientpb.ImplantConfig

GetActiveSessionConfig - Get the active sessions's config TODO: Switch to query config based on ConfigID.

func (*SliverClient) GetPrompt added in v1.6.0

func (con *SliverClient) GetPrompt() string

func (*SliverClient) GetSession added in v1.6.0

func (con *SliverClient) GetSession(arg string) *clientpb.Session

func (*SliverClient) GetSessionsByName added in v1.6.0

func (con *SliverClient) GetSessionsByName(name string) []*clientpb.Session

GetSessionsByName - Return all sessions for an Implant by name.

func (*SliverClient) GrpcContext added in v1.6.0

func (con *SliverClient) GrpcContext(cmd *cobra.Command) (context.Context, context.CancelFunc)

GrpcContext - Generate a context for a GRPC request, if no grumble context or an invalid flag is provided 60 seconds is used instead.

func (*SliverClient) PrintAsyncResponse added in v1.6.0

func (con *SliverClient) PrintAsyncResponse(resp *commonpb.Response)

PrintAsyncResponse - Print the generic async response information.

func (*SliverClient) PrintErrorf added in v1.6.0

func (con *SliverClient) PrintErrorf(format string, args ...any)

PrintErrorf prints an error message immediately below the last line of output.

func (*SliverClient) PrintEventErrorf added in v1.6.0

func (con *SliverClient) PrintEventErrorf(format string, args ...any)

PrintEventErrorf prints an error message with a leading/trailing newline for emphasis.

func (*SliverClient) PrintEventInfof added in v1.6.0

func (con *SliverClient) PrintEventInfof(format string, args ...any)

PrintEventInfof prints an info message with a leading/trailing newline for emphasis.

func (*SliverClient) PrintEventSuccessf added in v1.6.0

func (con *SliverClient) PrintEventSuccessf(format string, args ...any)

PrintEventSuccessf a success message with a leading/trailing newline for emphasis.

func (*SliverClient) PrintInfof added in v1.6.0

func (con *SliverClient) PrintInfof(format string, args ...any)

PrintInfof prints an info message immediately below the last line of output.

func (con *SliverClient) PrintLogo()

func (*SliverClient) PrintSuccess added in v1.6.8

func (con *SliverClient) PrintSuccess(args ...any)

PrintSuccess prints a success message with a default or provided message.

func (*SliverClient) PrintSuccessf added in v1.6.0

func (con *SliverClient) PrintSuccessf(format string, args ...any)

PrintSuccessf prints a success message immediately below the last line of output.

func (*SliverClient) PrintWarnf added in v1.6.0

func (con *SliverClient) PrintWarnf(format string, args ...any)

PrintWarnf a warning message immediately below the last line of output.

func (*SliverClient) Printf added in v1.6.0

func (con *SliverClient) Printf(format string, args ...any)

func (*SliverClient) Println added in v1.6.0

func (con *SliverClient) Println(args ...any)

Println prints an output without status and immediately below the last line of output.

func (*SliverClient) RemoveEventListener added in v1.6.0

func (con *SliverClient) RemoveEventListener(listenerID string)

RemoveEventListener - removes an event listener given its id.

func (*SliverClient) SetConnection added in v1.7.1

func (con *SliverClient) SetConnection(rpc rpcpb.SliverRPCClient, grpcConn *grpc.ClientConn, details *ConnectionDetails) error

SetConnection swaps the active RPC connection, restarting streams (events/tunnels/logs). It is safe to call multiple times (e.g., on server switch).

func (*SliverClient) SpinUntil added in v1.6.0

func (con *SliverClient) SpinUntil(message string, ctrl chan bool)

type TextStyle added in v1.7.1

type TextStyle = lipgloss.Style

TextStyle is the shared styling type for the client/server consoles. Keep this type in the console package so most callsites don't need to import lipgloss directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL