extensions

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: GPL-3.0 Imports: 23 Imported by: 3

README

Extensions

Allows to load and execute 3rd party extensions.

Extensions directory structures can be arbitrary, however in the root of the directory or .tar.gz there must be a extension.json or a alias.json file. All paths are relative to the manifest/root directory, parent directories are not allowed. Only files listed in the manifest are copied, any other files will be ignored.

/path/to/extension/folder/
├── extension.json
└── windows
│    └── extension.x86.dll
│    └── extension.x64.dll
└── linux
│    └── extension.x86.so
│    └── extension.x64.so
└── darwin
     └── extension.x86.dylib
     └── extension.x64.dylib

Here's an example manifest (i.e., the extension.json or a alias.json):

{
    "name": "foo",
    "version": "1.0.0",
    "extension_author": "ac1d-burn",
    "original_author": "zer0-cool",
    "repo_url": "https://github.com/foo/bar",
    "help": "Help for foo command",
    "entrypoint": "RunFoo",
    "init" :"NimMain",
    "depends_on": "bar",
    "files": [
        {
            "os": "windows",
            "arch": "amd64",
            "path": "extension.x64.o",
        }
    ],
    "arguments": [
        {"name": "pid", "type": "int", "desc": "pid", "optional": false},
    ]
}

The structure is the following one:

  • name: name of the extension, which will also be the name of the command in the sliver client
  • help: the documentation for the new command
  • entrypoint: the name of the exported function to call
  • files: a list of object pointing to the extensions files to load for each architectures and operating systems
  • init: the initialization function name (if relevant, can be omitted)
  • arguments: an optional list of objects (for DLLs), but mandatory for BOFs
  • depends_on: the name of an extension required by the current extension (won't load if the dependency is not loaded)

The type of an argument can be one of the following:

  • string: regular ASCII string
  • wstring: string that will be UTF16 encoded
  • int: will be parsed as a 32 bit unsigned integer
  • short: will be parsed as a 16 bit unsigned integer
  • file: a string to a file path on the client side which content will be passed to the BOF

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, app *grumble.App) bool

CmdExists - checks if a command exists

func ExtensionLoadCmd added in v1.5.0

func ExtensionLoadCmd(ctx *grumble.Context, con *console.SliverConsoleClient)

ExtensionLoadCmd - Load extension command

func ExtensionRegisterCommand added in v1.5.0

func ExtensionRegisterCommand(extCmd *ExtensionManifest, con *console.SliverConsoleClient)

ExtensionRegisterCommand - Register a new extension command

func ExtensionsCmd added in v1.5.0

func ExtensionsCmd(ctx *grumble.Context, con *console.SliverConsoleClient)

ExtensionsCmd - List information about installed extensions

func ExtensionsCommandNameCompleter added in v1.5.0

func ExtensionsCommandNameCompleter(prefix string, args []string, con *console.SliverConsoleClient) []string

ExtensionsCommandNameCompleter - Completer for installed extensions command names

func ExtensionsInstallCmd added in v1.5.0

func ExtensionsInstallCmd(ctx *grumble.Context, con *console.SliverConsoleClient)

ExtensionsInstallCmd - Install an extension

func ExtensionsListCmd added in v1.5.0

func ExtensionsListCmd(ctx *grumble.Context, con *console.SliverConsoleClient)

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

func ExtensionsRemoveCmd added in v1.5.0

func ExtensionsRemoveCmd(ctx *grumble.Context, con *console.SliverConsoleClient)

ExtensionsRemoveCmd - Remove an extension

func InstallFromFilePath added in v1.5.0

func InstallFromFilePath(extLocalPath string, autoOverwrite bool, con *console.SliverConsoleClient) *string

InstallFromFilePath - Install an extension from a .tar.gz file

func PrintExtOutput added in v1.5.0

func PrintExtOutput(extName string, commandName string, callExtension *sliverpb.CallExtension, con *console.SliverConsoleClient)

PrintExtOutput - Print the ext execution output

func PrintExtensions added in v1.5.0

func PrintExtensions(con *console.SliverConsoleClient)

PrintExtensions - Print a list of loaded extensions

func RemoveExtensionByCommandName added in v1.5.0

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

RemoveExtensionByCommandName - Remove an extension by command name

Types

type ExtensionManifest added in v1.5.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"`
	Files           []*extensionFile     `json:"files"`
	Arguments       []*extensionArgument `json:"arguments"`
	Entrypoint      string               `json:"entrypoint"`
	DependsOn       string               `json:"depends_on"`
	Init            string               `json:"init"`

	RootPath string `json:"-"`
}

func LoadExtensionManifest added in v1.5.0

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

LoadExtensionManifest - Parse extension files

func ParseExtensionManifest added in v1.5.0

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

ParseExtensionManifest - Parse extension manifest from buffer

Jump to

Keyboard shortcuts

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