extensions

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: GPL-3.0 Imports: 36 Imported by: 3

README

client/command/extensions

Overview

Implements the 'extensions' command group for the Sliver client console. Handlers map Cobra invocations to extensions workflows such as argparser, install, list, and load.

Go Files

  • argparser.go – Builds argument buffers for extensions, including BOF-specific marshaling and validation.
  • commands.go – Declares the extensions command tree and binds subcommands for list, install, load, and remove actions.
  • extensions.go – Manages installed/temporary extension manifests, printing metadata and supplying completers.
  • extensions_test.go (tests) – Verifies manifest parsing and conversion routines to guard against format regressions.
  • install.go – Installs extension bundles from directories or archives, handling overwrite prompts and asset extraction.
  • list.go – Queries the server for matching extensions and renders results categorized by hash or type.
  • load.go – Loads extension binaries for the active target, registers generated commands, and dispatches execution RPCs.
  • remove.go – Removes installed extensions, coordinating manifest lookups and filesystem cleanup.

Documentation

Index

Constants

View Source
const (

	// ManifestFileName - Extension manifest file name.
	ManifestFileName = "extension.json"
)

Variables

This section is empty.

Functions

func CmdExists added in v1.5.0

func CmdExists(name string, cmd *cobra.Command) bool

CmdExists - checks if a command exists.

func Commands added in v1.6.0

func Commands(con *console.SliverClient) []*cobra.Command

Commands returns the 'extensions' command and its subcommands.

func ExtensionLoadCmd added in v1.5.0

func ExtensionLoadCmd(cmd *cobra.Command, con *console.SliverClient, args []string)

ExtensionLoadCmd - Temporarily installs an extension from a local directory into the client. The extension must contain a valid manifest file. If commands from the extension already exist, the user will be prompted to overwrite them.

func ExtensionRegisterCommand added in v1.5.0

func ExtensionRegisterCommand(extCmd *ExtCommand, cmd *cobra.Command, con *console.SliverClient)

ExtensionRegisterCommand adds an extension command to the cobra command system. It validates the extension's arguments, updates the loadedExtensions map, and creates a cobra.Command with proper usage text, help documentation, and argument handling. The command is added as a subcommand to the provided parent cobra.Command. Arguments are displayed in the help text as uppercase, with optional args in square brackets. The help text includes sections for command usage, description, and detailed argument specifications.

func ExtensionsCmd added in v1.5.0

func ExtensionsCmd(cmd *cobra.Command, con *console.SliverClient)

ExtensionsCmd - List information about installed extensions.

func ExtensionsCommandNameCompleter added in v1.5.0

func ExtensionsCommandNameCompleter(con *console.SliverClient) carapace.Action

ExtensionsCommandNameCompleter - Completer for installed extensions command names.

func ExtensionsInstallCmd added in v1.5.0

func ExtensionsInstallCmd(cmd *cobra.Command, con *console.SliverClient, args []string)

ExtensionsInstallCmd - Install an extension.

func ExtensionsListCmd added in v1.5.0

func ExtensionsListCmd(cmd *cobra.Command, con *console.SliverClient, args []string)

ExtensionsListCmd - List all extension loaded on the active session/beacon.

func ExtensionsRemoveCmd added in v1.5.0

func ExtensionsRemoveCmd(cmd *cobra.Command, con *console.SliverClient, args []string)

ExtensionsRemoveCmd - Remove an extension.

func FindExtensionMatches added in v1.6.0

func FindExtensionMatches(targetHashes []string) map[string]*ExtensionMatch

FindExtensionMatches searches through loaded extensions for matching hashes Returns a map of hash to ExtensionMatch (match will be nil if hash wasn't found)

func GetAllExtensionManifests added in v1.6.0

func GetAllExtensionManifests() []string

GetAllExtensionManifests returns a combined list of manifest file paths from both installed and temporarily loaded extensions

func InstallFromDir added in v1.6.0

func InstallFromDir(extLocalPath string, promptToOverwrite bool, con *console.SliverClient, isGz bool)

InstallFromDir installs a Sliver extension from either a local directory or gzipped archive. It reads the extension manifest, validates it, and copies all required files to the extensions directory. If an extension with the same name already exists, it can optionally prompt for overwrite confirmation.

Parameters:

  • extLocalPath: Path to the source directory or gzipped archive containing the extension
  • promptToOverwrite: If true, prompts for confirmation before overwriting existing extension
  • con: Sliver console client for displaying status and error messages
  • isGz: Whether the source is a gzipped archive (true) or directory (false)

The function will return early with error messages printed to console if:

  • The manifest cannot be read or parsed
  • Required directories cannot be created
  • File copy operations fail
  • User declines overwrite when prompted

func ManifestCompleter added in v1.6.0

func ManifestCompleter() carapace.Action

func ParseFlagArgumentsToBuffer added in v1.6.0

func ParseFlagArgumentsToBuffer(_ *cobra.Command, args []string, _ string, ext *ExtCommand) ([]byte, error)

ParseFlagArgumentsToBuffer parses flag-style arguments based on extension manifest and converts them to a BOF-compatible binary buffer

func PrintExtOutput added in v1.5.0

func PrintExtOutput(extName string, commandName string, outputSchema *packages.OutputSchema, callExtension *sliverpb.CallExtension, con *console.SliverClient)

PrintExtOutput - Print the ext execution output.

func PrintExtensionMatches added in v1.6.0

func PrintExtensionMatches(matches map[string]*ExtensionMatch, con *console.SliverClient)

PrintExtensionMatches prints the extension matches in a formatted table

func PrintExtensions added in v1.5.0

func PrintExtensions(con *console.SliverClient)

PrintExtensions - Print a list of loaded extensions.

func RemoveExtensionByCommandName added in v1.5.0

func RemoveExtensionByCommandName(commandName string, con *console.SliverClient) error

RemoveExtensionByCommandName - Remove an extension by command name.

func RemoveExtensionByManifestName added in v1.6.0

func RemoveExtensionByManifestName(manifestName string, con *console.SliverClient) (bool, error)

RemoveExtensionByManifestName - remove by the named manifest, returns true if manifest was removed, false if no manifest with that name was found

func SliverCommands added in v1.6.0

func SliverCommands(con *console.SliverClient) []*cobra.Command

Types

type ExtCommand added in v1.6.0

type ExtCommand struct {
	CommandName string                 `json:"command_name"`
	Help        string                 `json:"help"`
	LongHelp    string                 `json:"long_help"`
	Files       []*extensionFile       `json:"files"`
	Arguments   []*extensionArgument   `json:"arguments"`
	Entrypoint  string                 `json:"entrypoint"`
	DependsOn   string                 `json:"depends_on"`
	Init        string                 `json:"init"`
	Schema      *packages.OutputSchema `json:"schema"`

	Manifest *ExtensionManifest
}

type ExtensionManifest added in v1.5.0

type ExtensionManifest struct {
	Name            string `json:"name"`
	PackageName     string `json:"package_name"`
	Version         string `json:"version"`
	ExtensionAuthor string `json:"extension_author"`
	OriginalAuthor  string `json:"original_author"`
	RepoURL         string `json:"repo_url"`

	ExtCommand []*ExtCommand `json:"commands"`

	RootPath   string `json:"-"`
	ArmoryName string `json:"-"`
	ArmoryPK   string `json:"-"`
}

func LoadExtensionManifest added in v1.5.0

func LoadExtensionManifest(manifestPath string) (*ExtensionManifest, error)

LoadExtensionManifest loads and parses an extension manifest file from the given path. It registers each command defined in the manifest into the loadedExtensions map and registers the complete manifest into loadedManifests. A single manifest may contain multiple extension commands. The manifest's RootPath is set to its containing directory. Returns the parsed manifest and any errors encountered.

func ParseExtensionManifest added in v1.5.0

func ParseExtensionManifest(data []byte) (*ExtensionManifest, error)

parseExtensionManifest - Parse extension manifest from buffer (legacy, only parses one)

type ExtensionManifest_ added in v1.6.0

type ExtensionManifest_ struct {
	Name            string               `json:"name"`
	CommandName     string               `json:"command_name"`
	Version         string               `json:"version"`
	ExtensionAuthor string               `json:"extension_author"`
	OriginalAuthor  string               `json:"original_author"`
	RepoURL         string               `json:"repo_url"`
	Help            string               `json:"help"`
	LongHelp        string               `json:"long_help"`
	Files           []*extensionFile     `json:"files"`
	Arguments       []*extensionArgument `json:"arguments"`
	Entrypoint      string               `json:"entrypoint"`
	DependsOn       string               `json:"depends_on"`
	Init            string               `json:"init"`

	RootPath string `json:"-"`
}

type ExtensionMatch added in v1.6.0

type ExtensionMatch struct {
	CommandName string
	Hash        string
	BinPath     string
}

Jump to

Keyboard shortcuts

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