Skip to content

Commit

Permalink
Merge branch 'master' into extensionargs
Browse files Browse the repository at this point in the history
Signed-off-by: C_Sto <[email protected]>
  • Loading branch information
C-Sto authored Dec 20, 2023
2 parents 1205def + 478dabf commit dfaadfb
Show file tree
Hide file tree
Showing 50 changed files with 637 additions and 108 deletions.
4 changes: 2 additions & 2 deletions client/command/armory/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ func installExtension(extm *extensions.ExtensionManifest, clientConfig ArmoryHTT
deps := make(map[string]struct{})
for _, ext := range extm.ExtCommand {
resolveExtensionPackageDependencies(ext.CommandName, deps, clientConfig, con)
sliverMenu := con.App.Menu(constants.ImplantMenu)
sliverMenu := con.App.Menu(constants.ImplantMenu).Root()
for dep := range deps {
if extensions.CmdExists(dep, sliverMenu.Command) {
if extensions.CmdExists(dep, sliverMenu) {
continue // Dependency is already installed
}
err := installExtensionPackageByName(dep, clientConfig, con)
Expand Down
10 changes: 10 additions & 0 deletions client/command/extensions/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,13 @@ func ExtensionsCommandNameCompleter(con *console.SliverConsoleClient) carapace.A
return carapace.ActionValuesDescribed(results...).Tag("extension commands")
})
}

func ManifestCompleter() carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
results := []string{}
for k := range loadedManifests {
results = append(results, k)
}
return carapace.ActionValues(results...).Tag("extensions")
})
}
57 changes: 53 additions & 4 deletions client/command/extensions/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func LoadExtensionManifest(manifestPath string) (*ExtensionManifest, error) {
loadedManifests[manifest.Name] = manifest

return manifest, nil

}

func convertOldManifest(old *ExtensionManifest_) *ExtensionManifest {
Expand Down Expand Up @@ -268,13 +269,61 @@ func ExtensionRegisterCommand(extCmd *ExtCommand, cmd *cobra.Command, con *conso
}

loadedExtensions[extCmd.CommandName] = extCmd
helpMsg := extCmd.Help
//helpMsg := extCmd.Help

usage := strings.Builder{}
usage.WriteString(extCmd.CommandName)
//build usage including args
for _, arg := range extCmd.Arguments {
usage.WriteString(" ")
if arg.Optional {
usage.WriteString("[")
}
usage.WriteString(strings.ToUpper(arg.Name))
if arg.Optional {
usage.WriteString("]")
}
}
longHelp := strings.Builder{}
//prepend the help value, because otherwise I don't see where it is meant to be shown
//build the command ref
longHelp.WriteString("[[.Bold]]Command:[[.Normal]]")
longHelp.WriteString(usage.String())
longHelp.WriteString("\n")
if len(extCmd.Help) > 0 || len(extCmd.LongHelp) > 0 {
longHelp.WriteString("[[.Bold]]About:[[.Normal]]")
if len(extCmd.Help) > 0 {
longHelp.WriteString(extCmd.Help)
longHelp.WriteString("\n")
}
if len(extCmd.LongHelp) > 0 {
longHelp.WriteString(extCmd.LongHelp)
longHelp.WriteString("\n")
}
}
if len(extCmd.Arguments) > 0 {
longHelp.WriteString("[[.Bold]]Arguments:[[.Normal]]")
}
//if more than 0 args specified, describe each arg at the bottom of the long help text (incase the manifest doesn't include it)
for _, arg := range extCmd.Arguments {
longHelp.WriteString("\n\t")
optStr := ""
if arg.Optional {
optStr = "[OPTIONAL]"
}
aType := arg.Type
if aType == "wstring" {
aType = "string" //avoid confusion, as this is mostly for telling operator what to shove into the args
}
//idk how to make this look nice, tabs don't work especially good - maybe should use the table stuff other things do? Pls help.
longHelp.WriteString(fmt.Sprintf("%s (%s):\t%s%s", strings.ToUpper(arg.Name), aType, optStr, arg.Desc))
}

// Command
extensionCmd := &cobra.Command{
Use: extCmd.CommandName,
Short: helpMsg,
Long: help.FormatHelpTmpl(extCmd.LongHelp),
Use: usage.String(), //extCmd.CommandName,
//Short: helpMsg.String(), doesn't appear to be used?
Long: help.FormatHelpTmpl(longHelp.String()),
Run: func(cmd *cobra.Command, args []string) {
runExtensionCmd(cmd, con, args)
},
Expand Down
40 changes: 22 additions & 18 deletions client/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,27 @@ func ServerCommands(con *client.SliverConsoleClient, serverCmds func() []*cobra.
}
server.AddCommand(extCmd)

extLoadCmd := &cobra.Command{
Use: consts.LoadStr + " [EXT]",
Short: "Load a command EXT",
Long: help.GetHelpFor([]string{consts.ExtensionsStr, consts.LoadStr}),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
extensions.ExtensionLoadCmd(cmd, con, args)
},
}
carapace.Gen(extLoadCmd).PositionalCompletion(
carapace.ActionDirectories().Tag("ext directory").Usage("path to the ext directory"))
extCmd.AddCommand(extLoadCmd)

/*
parking 'load' for now - the difference between 'load' and 'install' is that 'load' should not move binaries and manifests to the client install dir.
Maybe we can revisit this if it's required - but the usecase I can think of is when developing extensions, and that will also occasionally require a manifest update
// extLoadCmd := &cobra.Command{
// Use: consts.LoadStr + " [EXT]",
// Short: "Load a command EXT",
// Long: help.GetHelpFor([]string{consts.ExtensionsStr, consts.LoadStr}),
// Args: cobra.ExactArgs(1),
// Run: func(cmd *cobra.Command, args []string) {
// extensions.ExtensionLoadCmd(cmd, con, args)
// },
// }
// carapace.Gen(extLoadCmd).PositionalCompletion(
// carapace.ActionDirectories().Tag("ext directory").Usage("path to the ext directory"))
// extCmd.AddCommand(extLoadCmd)
*/

extInstallCmd := &cobra.Command{
Use: consts.InstallStr + " [EXT]",
Short: "Install a command ext",
Use: consts.InstallStr + " [filepath]",
Short: "Install an extension from a local directory/file.",
Long: help.GetHelpFor([]string{consts.ExtensionsStr, consts.InstallStr}),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -188,16 +193,15 @@ func ServerCommands(con *client.SliverConsoleClient, serverCmds func() []*cobra.
extCmd.AddCommand(extInstallCmd)

extendo := &cobra.Command{
Use: consts.RmStr + " [EXT]",
Short: "Remove an ext",
Use: consts.RmStr + " [Name]",
Short: "Remove extension. Will remove all commands associated with the installed extension. Does not unload the extension from implants that have already loaded it, but removes the command from the client.",
Long: help.GetHelpFor([]string{consts.RmStr}),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
//alias.AliasesRemoveCmd(cmd, con, args)
extensions.ExtensionsRemoveCmd(cmd, con, args)
},
}
carapace.Gen(extendo).PositionalCompletion(carapace.ActionFiles().Tag("ext I guess?"))
carapace.Gen(extendo).PositionalCompletion(extensions.ManifestCompleter())
extCmd.AddCommand(extendo)

// [ Armory ] ---------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/sliver-docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# generated files
public/sitemap.json
public/docs.json
/www.zip

# code editor files
.vscode/
Expand Down
30 changes: 30 additions & 0 deletions docs/sliver-docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Sliver Docs

The source code for the Sliver documentation site.

### Developers

To run the documentation site locally first install the dependencies and then run the `dev` npm script:

```bash
npm install
npm run dev
```

**NOTE:** The markdown is compiled into a static JSON object at build time. This means if you edit a `.md` file you will need to restart the dev server to see your changes.

### Offline Docs

To run your own copy of the documentation first install the dependencies and then run the `offline` npm script:

```bash
npm install
npm run offline
```

This will produce a `www.zip` file that contains the static html and JavaScript for the documentation site. You can extract this archive and host it anywhere:

```bash
unzip -o www.zip
cd out/
python -m http.server 8000
```

Then open your browser to `http://localhost:8000/` to view the documentation.
3 changes: 2 additions & 1 deletion docs/sliver-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"offline": "next build && zip -r www.zip ./out"
},
"dependencies": {
"@fontsource/fira-code": "^5.0.16",
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ require (
github.com/things-go/go-socks5 v0.0.3
github.com/xlab/treeprint v1.2.0
github.com/yiya1989/sshkrb5 v0.0.1
golang.org/x/crypto v0.15.0
golang.org/x/crypto v0.17.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/net v0.17.0
golang.org/x/sys v0.14.0
golang.org/x/term v0.14.0
golang.org/x/sys v0.15.0
golang.org/x/term v0.15.0
golang.org/x/text v0.14.0
golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220208144051-fde48d68ee68
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220208050332-20e1d8d225ab/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
Expand Down Expand Up @@ -528,12 +528,12 @@ golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.1-0.20230131160137-e7d7f63158de/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
12 changes: 6 additions & 6 deletions vendor/golang.org/x/crypto/argon2/blamka_amd64.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions vendor/golang.org/x/crypto/blake2b/blake2b_amd64.go

This file was deleted.

2 changes: 0 additions & 2 deletions vendor/golang.org/x/crypto/blake2b/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions vendor/golang.org/x/crypto/ssh/channel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dfaadfb

Please sign in to comment.