From 2e4ab0a3bba236e65486d9c95ad93193a3d80507 Mon Sep 17 00:00:00 2001 From: moloch-- <875022+moloch--@users.noreply.github.com> Date: Sun, 4 Jul 2021 10:53:04 -0500 Subject: [PATCH 1/5] Move lic --- client/command/loot/rename.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/command/loot/rename.go b/client/command/loot/rename.go index eae62910a9..cb7b07f467 100644 --- a/client/command/loot/rename.go +++ b/client/command/loot/rename.go @@ -1,14 +1,5 @@ package loot -import ( - "context" - - "github.com/AlecAivazis/survey/v2" - "github.com/bishopfox/sliver/client/console" - "github.com/bishopfox/sliver/protobuf/clientpb" - "github.com/desertbit/grumble" -) - /* Sliver Implant Framework Copyright (C) 2021 Bishop Fox @@ -27,6 +18,15 @@ import ( along with this program. If not, see . */ +import ( + "context" + + "github.com/AlecAivazis/survey/v2" + "github.com/bishopfox/sliver/client/console" + "github.com/bishopfox/sliver/protobuf/clientpb" + "github.com/desertbit/grumble" +) + func LootRenameCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { loot, err := SelectLoot(ctx, con.Rpc) if err != nil { From 9a5d6948fe953e59b68cee6f707ad2fcff75212f Mon Sep 17 00:00:00 2001 From: moloch-- <875022+moloch--@users.noreply.github.com> Date: Sun, 4 Jul 2021 13:08:15 -0500 Subject: [PATCH 2/5] Added export comments to client/command --- client/command/backdoor/backdoor.go | 1 + client/command/environment/get.go | 1 + client/command/environment/set.go | 1 + client/command/environment/unset.go | 1 + client/command/exec/execute-assembly.go | 1 + client/command/exec/execute-shellcode.go | 1 + client/command/exec/execute.go | 1 + client/command/exec/migrate.go | 1 + client/command/exec/msf-inject.go | 1 + client/command/exec/msf.go | 1 + client/command/exec/psexec.go | 1 + client/command/exec/sideload.go | 1 + client/command/exec/spawndll.go | 1 + client/command/exec/ssh.go | 1 + client/command/extensions/load.go | 1 + client/command/filesystem/cat.go | 1 + client/command/filesystem/cd.go | 1 + client/command/filesystem/download.go | 1 + client/command/filesystem/ls.go | 1 + client/command/filesystem/mkdir.go | 1 + client/command/filesystem/pwd.go | 1 + client/command/filesystem/rm.go | 1 + client/command/filesystem/upload.go | 1 + client/command/generate/canaries.go | 1 + client/command/generate/generate-info.go | 1 + client/command/generate/generate-stager.go | 1 + client/command/generate/generate.go | 1 + client/command/generate/helpers.go | 1 + client/command/generate/implants-rm.go | 1 + client/command/generate/implants.go | 1 + client/command/generate/profiles-generate.go | 1 + client/command/generate/profiles-new.go | 1 + client/command/generate/profiles-rm.go | 1 + client/command/generate/profiles.go | 1 + client/command/generate/regenerate.go | 1 + client/command/help/help.go | 1 + client/command/info/info.go | 5 ++ client/command/info/ping.go | 1 + client/command/jobs/dns.go | 1 + client/command/jobs/http.go | 1 + client/command/jobs/https.go | 1 + client/command/jobs/jobs.go | 1 + client/command/jobs/mtls.go | 1 + client/command/jobs/wg.go | 1 + client/command/loot/add-credential.go | 1 + client/command/loot/fetch.go | 1 + client/command/loot/helpers.go | 55 ++++++++++++++++++ client/command/loot/local.go | 1 + client/command/loot/loot.go | 57 ++----------------- client/command/monitor/start.go | 1 + client/command/monitor/stop.go | 1 + client/command/network/ifconfig.go | 1 + client/command/network/netstat.go | 1 + client/command/operators/operators.go | 1 + client/command/pivots/named-pipe.go | 1 + client/command/pivots/pivots.go | 1 + client/command/pivots/tcp.go | 1 + client/command/portfwd/portfwd-add.go | 1 + client/command/portfwd/portfwd-rm.go | 1 + client/command/portfwd/portfwd.go | 1 + client/command/privilege/getsystem.go | 1 + client/command/privilege/impersonate.go | 1 + client/command/privilege/make-token.go | 1 + client/command/privilege/rev2self.go | 1 + client/command/privilege/runas.go | 1 + client/command/processes/procdump.go | 1 + client/command/processes/ps.go | 1 + client/command/processes/terminate.go | 1 + client/command/registry/reg-create.go | 1 + client/command/registry/reg-read.go | 2 +- client/command/registry/reg-write.go | 2 +- client/command/screenshot/screenshot.go | 1 + client/command/sessions/background.go | 1 + client/command/sessions/helpers.go | 1 + client/command/sessions/kill.go | 1 + client/command/sessions/prune.go | 1 + client/command/sessions/reconfig.go | 1 + client/command/sessions/sessions.go | 1 + client/command/sessions/use.go | 1 + client/command/shell/shell.go | 3 +- client/command/update/update.go | 2 + .../command/websites/websites-add-content.go | 1 + .../command/websites/websites-rm-content.go | 1 + client/command/websites/websites-rm.go | 1 + .../websites/websites-update-content.go | 1 + client/command/websites/websites.go | 3 + client/command/wireguard/wg-config.go | 1 + client/command/wireguard/wg-portfwd-add.go | 1 + client/command/wireguard/wg-portfwd-rm.go | 1 + client/command/wireguard/wg-portfwd.go | 1 + client/command/wireguard/wg-socks-start.go | 1 + client/command/wireguard/wg-socks-stop.go | 1 + client/command/wireguard/wg-socks.go | 1 + 93 files changed, 158 insertions(+), 56 deletions(-) diff --git a/client/command/backdoor/backdoor.go b/client/command/backdoor/backdoor.go index 007a46dc72..3d79f9e8f0 100644 --- a/client/command/backdoor/backdoor.go +++ b/client/command/backdoor/backdoor.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// BackdoorCmd - Command to inject implant code into an existing binary func BackdoorCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/environment/get.go b/client/command/environment/get.go index b85ae451b1..c0db059bf9 100644 --- a/client/command/environment/get.go +++ b/client/command/environment/get.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// EnvGetCmd - Get a remote environment variable func EnvGetCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/environment/set.go b/client/command/environment/set.go index 5f58484761..571bf4276d 100644 --- a/client/command/environment/set.go +++ b/client/command/environment/set.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// EnvSetCmd - Set a remote environment variable func EnvSetCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/environment/unset.go b/client/command/environment/unset.go index c9fc023cb0..8b6556bc71 100644 --- a/client/command/environment/unset.go +++ b/client/command/environment/unset.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// EnvUnsetCmd - Unset a remote environment variable func EnvUnsetCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/exec/execute-assembly.go b/client/command/exec/execute-assembly.go index bcaa5eec2c..8c7a0fbf08 100644 --- a/client/command/exec/execute-assembly.go +++ b/client/command/exec/execute-assembly.go @@ -30,6 +30,7 @@ import ( "github.com/desertbit/grumble" ) +// ExecuteAssemblyCmd - Execute a .NET assembly in-memory func ExecuteAssemblyCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/exec/execute-shellcode.go b/client/command/exec/execute-shellcode.go index 03fdc368ce..c8572aae47 100644 --- a/client/command/exec/execute-shellcode.go +++ b/client/command/exec/execute-shellcode.go @@ -35,6 +35,7 @@ import ( "github.com/desertbit/grumble" ) +// ExecuteShellcodeCmd - Execute shellcode in-memory func ExecuteShellcodeCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/exec/execute.go b/client/command/exec/execute.go index 7f5ddb3e0d..886d64aae5 100644 --- a/client/command/exec/execute.go +++ b/client/command/exec/execute.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// Execute - Run a command on the remote system func ExecuteCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/exec/migrate.go b/client/command/exec/migrate.go index 14d7d1222b..223652d25e 100644 --- a/client/command/exec/migrate.go +++ b/client/command/exec/migrate.go @@ -24,6 +24,7 @@ import ( "github.com/desertbit/grumble" ) +// MigrateCmd - Windows only, inject an implant into another process func MigrateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/exec/msf-inject.go b/client/command/exec/msf-inject.go index 7b7f3df23c..be33fa3f67 100644 --- a/client/command/exec/msf-inject.go +++ b/client/command/exec/msf-inject.go @@ -29,6 +29,7 @@ import ( "github.com/desertbit/grumble" ) +// MsfInjectCmd - Inject a metasploit payload into a remote process func MsfInjectCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/exec/msf.go b/client/command/exec/msf.go index b269349bf4..0c32240bb1 100644 --- a/client/command/exec/msf.go +++ b/client/command/exec/msf.go @@ -29,6 +29,7 @@ import ( "github.com/desertbit/grumble" ) +// MsfCmd - Inject a metasploit payload into the current remote process func MsfCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/exec/psexec.go b/client/command/exec/psexec.go index 536802a3c8..a7d1af87f6 100644 --- a/client/command/exec/psexec.go +++ b/client/command/exec/psexec.go @@ -34,6 +34,7 @@ import ( "github.com/desertbit/grumble" ) +// PsExecCmd - psexec command implementation. func PsExecCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/exec/sideload.go b/client/command/exec/sideload.go index 939b8879fa..57a4ea6194 100644 --- a/client/command/exec/sideload.go +++ b/client/command/exec/sideload.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// SideloadCmd - Sideload a shared library on the remote system func SideloadCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/exec/spawndll.go b/client/command/exec/spawndll.go index b93f60c6c9..edeb17d2ef 100644 --- a/client/command/exec/spawndll.go +++ b/client/command/exec/spawndll.go @@ -13,6 +13,7 @@ import ( "github.com/desertbit/grumble" ) +// SpawnDllCmd - Spawn execution of a DLL on the remote system func SpawnDllCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/exec/ssh.go b/client/command/exec/ssh.go index 0eb61e01ee..fb275fe015 100644 --- a/client/command/exec/ssh.go +++ b/client/command/exec/ssh.go @@ -13,6 +13,7 @@ import ( "github.com/desertbit/grumble" ) +// SSHCmd - A built-in SSH client command for the remote system (doesn't shell out) func SSHCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { var ( privKey []byte diff --git a/client/command/extensions/load.go b/client/command/extensions/load.go index 63f1b3274c..85e929804c 100644 --- a/client/command/extensions/load.go +++ b/client/command/extensions/load.go @@ -121,6 +121,7 @@ func (e *extension) getCommandFromName(name string) (extCmd *extensionCommand, e return } +// LoadExtensionCmd - Locally load an extension into the Sliver shell. func LoadExtensionCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { dirPath := ctx.Args.String("dir-path") diff --git a/client/command/filesystem/cat.go b/client/command/filesystem/cat.go index 606a35ef25..7fcf8ae0fe 100644 --- a/client/command/filesystem/cat.go +++ b/client/command/filesystem/cat.go @@ -33,6 +33,7 @@ import ( "github.com/desertbit/grumble" ) +// CatCmd - Display the contents of a remote file func CatCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/cd.go b/client/command/filesystem/cd.go index 90d7adeb7f..81174f9239 100644 --- a/client/command/filesystem/cd.go +++ b/client/command/filesystem/cd.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// CdCmd - Change directory on the remote system func CdCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/download.go b/client/command/filesystem/download.go index 2bf3101b47..1d470c85cf 100644 --- a/client/command/filesystem/download.go +++ b/client/command/filesystem/download.go @@ -33,6 +33,7 @@ import ( "github.com/desertbit/grumble" ) +// DownloadCmd - Download a file from the remote system func DownloadCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/ls.go b/client/command/filesystem/ls.go index 541e1aa2a6..abdbb680b5 100644 --- a/client/command/filesystem/ls.go +++ b/client/command/filesystem/ls.go @@ -32,6 +32,7 @@ import ( "github.com/desertbit/grumble" ) +// LsCmd - List the contents of a remote directory func LsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/mkdir.go b/client/command/filesystem/mkdir.go index c465b85644..fc5cc119c3 100644 --- a/client/command/filesystem/mkdir.go +++ b/client/command/filesystem/mkdir.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// MkdirCmd - Make a remote directory func MkdirCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/pwd.go b/client/command/filesystem/pwd.go index 5639f47957..efea9f6fa6 100644 --- a/client/command/filesystem/pwd.go +++ b/client/command/filesystem/pwd.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// PwdCmd - Print the remote working directory func PwdCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/rm.go b/client/command/filesystem/rm.go index a310e0f533..5e8f379304 100644 --- a/client/command/filesystem/rm.go +++ b/client/command/filesystem/rm.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// RmCmd - Remove a directory from the remote file system func RmCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/filesystem/upload.go b/client/command/filesystem/upload.go index deb4d5c206..f6f6209a45 100644 --- a/client/command/filesystem/upload.go +++ b/client/command/filesystem/upload.go @@ -32,6 +32,7 @@ import ( "github.com/desertbit/grumble" ) +// UploadCmd - Upload a file to the remote system func UploadCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/generate/canaries.go b/client/command/generate/canaries.go index d53ccdb97a..8b2666653d 100644 --- a/client/command/generate/canaries.go +++ b/client/command/generate/canaries.go @@ -13,6 +13,7 @@ import ( "github.com/desertbit/grumble" ) +// CanariesCmd - Display canaries from the database and their status func CanariesCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { canaries, err := con.Rpc.Canaries(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/generate/generate-info.go b/client/command/generate/generate-info.go index f90cebab46..ce062e8043 100644 --- a/client/command/generate/generate-info.go +++ b/client/command/generate/generate-info.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// GenerateInfoCmd - Display information about the Sliver server's compiler configuration func GenerateInfoCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { compiler, err := con.Rpc.GetCompiler(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/generate/generate-stager.go b/client/command/generate/generate-stager.go index 55e14297a5..a4f6547bbc 100644 --- a/client/command/generate/generate-stager.go +++ b/client/command/generate/generate-stager.go @@ -16,6 +16,7 @@ import ( "github.com/desertbit/grumble" ) +// GenerateStagerCmd - Generate a stager using Metasploit func GenerateStagerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { var stageProto clientpb.StageProtocol lhost := ctx.Flags.String("lhost") diff --git a/client/command/generate/generate.go b/client/command/generate/generate.go index ebf09786d9..f36737e898 100644 --- a/client/command/generate/generate.go +++ b/client/command/generate/generate.go @@ -93,6 +93,7 @@ var ( // } ) +// GenerateCmd - The main command used to generate implant binaries func GenerateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { config := parseCompileFlags(ctx, con) if config == nil { diff --git a/client/command/generate/helpers.go b/client/command/generate/helpers.go index 80673b6e59..a9a01ab9ef 100644 --- a/client/command/generate/helpers.go +++ b/client/command/generate/helpers.go @@ -8,6 +8,7 @@ import ( "github.com/bishopfox/sliver/protobuf/commonpb" ) +// GetSliverBinary - Get the binary of an implant based on it's profile func GetSliverBinary(profile *clientpb.ImplantProfile, con *console.SliverConsoleClient) ([]byte, error) { var data []byte // get implant builds diff --git a/client/command/generate/implants-rm.go b/client/command/generate/implants-rm.go index db2b3320a6..b47874fa31 100644 --- a/client/command/generate/implants-rm.go +++ b/client/command/generate/implants-rm.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// ImplantsRmCmd - Deletes an archived implant build from the server func ImplantsRmCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { _, err := con.Rpc.DeleteImplantBuild(context.Background(), &clientpb.DeleteReq{ Name: ctx.Args.String("implant-name"), diff --git a/client/command/generate/implants.go b/client/command/generate/implants.go index c035b9f505..03f1646011 100644 --- a/client/command/generate/implants.go +++ b/client/command/generate/implants.go @@ -32,6 +32,7 @@ import ( "github.com/desertbit/grumble" ) +// ImplantsCmd - Displays archived implant builds func ImplantsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { builds, err := con.Rpc.ImplantBuilds(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/generate/profiles-generate.go b/client/command/generate/profiles-generate.go index b37236b23d..39758b55df 100644 --- a/client/command/generate/profiles-generate.go +++ b/client/command/generate/profiles-generate.go @@ -28,6 +28,7 @@ import ( "github.com/desertbit/grumble" ) +// ProfilesGenerateCmd - Generate an implant binary based on a profile func ProfilesGenerateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { name := ctx.Flags.String("name") if name == "" { diff --git a/client/command/generate/profiles-new.go b/client/command/generate/profiles-new.go index 81767152e0..ff423a6f79 100644 --- a/client/command/generate/profiles-new.go +++ b/client/command/generate/profiles-new.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// ProfilesNewCmd - Create a new implant profile func ProfilesNewCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { name := ctx.Flags.String("profile-name") if name == "" { diff --git a/client/command/generate/profiles-rm.go b/client/command/generate/profiles-rm.go index 6c45045a2c..66df25d377 100644 --- a/client/command/generate/profiles-rm.go +++ b/client/command/generate/profiles-rm.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// ProfilesRmCmd - Delete an implant profile func ProfilesRmCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { _, err := con.Rpc.DeleteImplantProfile(context.Background(), &clientpb.DeleteReq{ Name: ctx.Args.String("profile-name"), diff --git a/client/command/generate/profiles.go b/client/command/generate/profiles.go index f379a118ba..0f76c2d135 100644 --- a/client/command/generate/profiles.go +++ b/client/command/generate/profiles.go @@ -32,6 +32,7 @@ import ( "github.com/desertbit/grumble" ) +// ProfilesCmd - Display implant profiles func ProfilesCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { profiles := getImplantProfiles(con) if profiles == nil { diff --git a/client/command/generate/regenerate.go b/client/command/generate/regenerate.go index be18acc6c1..92eec58430 100644 --- a/client/command/generate/regenerate.go +++ b/client/command/generate/regenerate.go @@ -28,6 +28,7 @@ import ( "github.com/desertbit/grumble" ) +// RegenerateCmd - Download an archived implant build/binary func RegenerateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { save := ctx.Flags.String("save") if save == "" { diff --git a/client/command/help/help.go b/client/command/help/help.go index eb93486da4..26e1adfe76 100644 --- a/client/command/help/help.go +++ b/client/command/help/help.go @@ -29,6 +29,7 @@ import ( "github.com/desertbit/grumble" ) +// HelpCmd - Returns an instance of the 'help' command func HelpCmd(con *console.SliverConsoleClient) func(a *grumble.App, shell bool) { return func(a *grumble.App, shell bool) { printHelp(con) diff --git a/client/command/info/info.go b/client/command/info/info.go index 2c7ab7940d..db8bce32dd 100644 --- a/client/command/info/info.go +++ b/client/command/info/info.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// InfoCmd - Display information about the active session func InfoCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { var session *clientpb.Session @@ -57,6 +58,7 @@ func InfoCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { } } +// PIDCmd - Get the active session's PID func PIDCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { @@ -65,6 +67,7 @@ func PIDCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { con.Printf("%d\n", session.PID) } +// UIDCmd - Get the active session's UID func UIDCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { @@ -73,6 +76,7 @@ func UIDCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { con.Printf("%s\n", session.UID) } +// GIDCmd - Get the active session's GID func GIDCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { @@ -81,6 +85,7 @@ func GIDCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { con.Printf("%s\n", session.GID) } +// WhoamiCmd - Displays the current user of the active session func WhoamiCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/info/ping.go b/client/command/info/ping.go index f9745882a9..f54ab8629e 100644 --- a/client/command/info/ping.go +++ b/client/command/info/ping.go @@ -9,6 +9,7 @@ import ( "github.com/desertbit/grumble" ) +// PingCmd - Send a round trip C2 message to an implant (does not use ICMP) func PingCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/jobs/dns.go b/client/command/jobs/dns.go index f12e3030df..3388a125f4 100644 --- a/client/command/jobs/dns.go +++ b/client/command/jobs/dns.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// DNSListenerCmd - Start a DNS lisenter func DNSListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { domains := strings.Split(ctx.Flags.String("domains"), ",") diff --git a/client/command/jobs/http.go b/client/command/jobs/http.go index aa2dfb6e70..647f9afdd2 100644 --- a/client/command/jobs/http.go +++ b/client/command/jobs/http.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// HTTPListenerCmd - Start an HTTP listener func HTTPListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { domain := ctx.Flags.String("domain") lport := uint16(ctx.Flags.Int("lport")) diff --git a/client/command/jobs/https.go b/client/command/jobs/https.go index 66f5831bdf..a213b045bd 100644 --- a/client/command/jobs/https.go +++ b/client/command/jobs/https.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// HTTPSListenerCmd - Start an HTTPS listener func HTTPSListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { domain := ctx.Flags.String("domain") website := ctx.Flags.String("website") diff --git a/client/command/jobs/jobs.go b/client/command/jobs/jobs.go index cfef2e9dd5..c43cbc0d7f 100644 --- a/client/command/jobs/jobs.go +++ b/client/command/jobs/jobs.go @@ -33,6 +33,7 @@ import ( "github.com/desertbit/grumble" ) +// JobsCmd - Manage server jobs (listeners, etc) func JobsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { if ctx.Flags.Int("kill") != -1 { jobKill(uint32(ctx.Flags.Int("kill")), con) diff --git a/client/command/jobs/mtls.go b/client/command/jobs/mtls.go index 5db9640d8d..a4d334a509 100644 --- a/client/command/jobs/mtls.go +++ b/client/command/jobs/mtls.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// MTLSListenerCmd - Start an mTLS listener func MTLSListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { server := ctx.Flags.String("server") lport := uint16(ctx.Flags.Int("lport")) diff --git a/client/command/jobs/wg.go b/client/command/jobs/wg.go index d5c4915f39..1285a8407d 100644 --- a/client/command/jobs/wg.go +++ b/client/command/jobs/wg.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// WGListenerCmd - Start a WireGuard listener func WGListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { lport := uint16(ctx.Flags.Int("lport")) nport := uint16(ctx.Flags.Int("nport")) diff --git a/client/command/loot/add-credential.go b/client/command/loot/add-credential.go index b2a73c4778..bb950dc36c 100644 --- a/client/command/loot/add-credential.go +++ b/client/command/loot/add-credential.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// LootAddCredentialCmd - Add a credential type loot func LootAddCredentialCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { prompt := &survey.Select{ Message: "Choose a credential type:", diff --git a/client/command/loot/fetch.go b/client/command/loot/fetch.go index 169ad2a126..eb3d842768 100644 --- a/client/command/loot/fetch.go +++ b/client/command/loot/fetch.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// LootFetchCmd - Display the contents of or download a piece of loot func LootFetchCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { loot, err := SelectLoot(ctx, con.Rpc) if err != nil { diff --git a/client/command/loot/helpers.go b/client/command/loot/helpers.go index 8d12cae006..b211e334c3 100644 --- a/client/command/loot/helpers.go +++ b/client/command/loot/helpers.go @@ -36,6 +36,7 @@ import ( "github.com/bishopfox/sliver/protobuf/clientpb" "github.com/bishopfox/sliver/protobuf/commonpb" "github.com/bishopfox/sliver/protobuf/rpcpb" + "github.com/desertbit/grumble" ) var ( @@ -106,6 +107,7 @@ func AddLootAPIKey(rpc rpcpb.SliverRPCClient, name string, apiKey string) error return err } +// SelectCredentials - An interactive menu for the user to select a piece of loot func SelectCredentials(con *console.SliverConsoleClient) (*clientpb.Loot, error) { allLoot, err := con.Rpc.LootAllOf(context.Background(), &clientpb.Loot{ Type: clientpb.LootType_LOOT_CREDENTIAL, @@ -143,3 +145,56 @@ func SelectCredentials(con *console.SliverConsoleClient) (*clientpb.Loot, error) } return nil, errors.New("loot not found") } + +// SelectLoot - Interactive menu for the user to select a piece loot (all types) +func SelectLoot(ctx *grumble.Context, rpc rpcpb.SliverRPCClient) (*clientpb.Loot, error) { + + // Fetch data with optional filter + filter := ctx.Flags.String("filter") + var allLoot *clientpb.AllLoot + var err error + if filter == "" { + allLoot, err = rpc.LootAll(context.Background(), &commonpb.Empty{}) + if err != nil { + return nil, err + } + } else { + lootType, err := lootTypeFromHumanStr(filter) + if err != nil { + return nil, ErrInvalidFileType + } + allLoot, err = rpc.LootAllOf(context.Background(), &clientpb.Loot{Type: lootType}) + if err != nil { + return nil, err + } + } + + // Render selection table + buf := bytes.NewBufferString("") + table := tabwriter.NewWriter(buf, 0, 2, 2, ' ', 0) + for _, loot := range allLoot.Loot { + fmt.Fprintf(table, "%s\t%s\t%s\t\n", loot.Name, loot.Type, loot.LootID) + } + table.Flush() + options := strings.Split(buf.String(), "\n") + options = options[:len(options)-1] + if len(options) == 0 { + return nil, errors.New("no loot to select from") + } + + selected := "" + prompt := &survey.Select{ + Message: "Select a piece of loot:", + Options: options, + } + err = survey.AskOne(prompt, &selected) + if err != nil { + return nil, err + } + for index, value := range options { + if value == selected { + return allLoot.Loot[index], nil + } + } + return nil, errors.New("loot not found") +} diff --git a/client/command/loot/local.go b/client/command/loot/local.go index 3b8b10dbec..0a9db69206 100644 --- a/client/command/loot/local.go +++ b/client/command/loot/local.go @@ -31,6 +31,7 @@ import ( "github.com/desertbit/grumble" ) +// LootAddLocalCmd - Add a local file to the server as loot func LootAddLocalCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { localPath := ctx.Args.String("path") if _, err := os.Stat(localPath); os.IsNotExist(err) { diff --git a/client/command/loot/loot.go b/client/command/loot/loot.go index f2eddd5a44..75e2079018 100644 --- a/client/command/loot/loot.go +++ b/client/command/loot/loot.go @@ -35,7 +35,6 @@ import ( "github.com/bishopfox/sliver/client/console" "github.com/bishopfox/sliver/protobuf/clientpb" "github.com/bishopfox/sliver/protobuf/commonpb" - "github.com/bishopfox/sliver/protobuf/rpcpb" "github.com/desertbit/grumble" ) @@ -75,6 +74,7 @@ func LootCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { } } +// PrintLootFile - Display the contents of a piece of loot func PrintLootFile(stdout io.Writer, loot *clientpb.Loot) { if loot.File == nil { return @@ -148,6 +148,7 @@ func saveLootToDisk(ctx *grumble.Context, loot *clientpb.Loot) (string, error) { return saveTo, err } +// PrintAllLootTable - Displays a table of all loot func PrintAllLootTable(stdout io.Writer, allLoot *clientpb.AllLoot) { if allLoot == nil || len(allLoot.Loot) == 0 { fmt.Fprintf(stdout, console.Info+"No loot 🙁\n") @@ -172,6 +173,7 @@ func PrintAllLootTable(stdout io.Writer, allLoot *clientpb.AllLoot) { fmt.Fprintf(stdout, outputBuf.String()) } +// PrintAllFileLootTable - Displays a table of all file loot func PrintAllFileLootTable(stdout io.Writer, allLoot *clientpb.AllLoot) { if allLoot == nil || len(allLoot.Loot) == 0 { fmt.Fprintf(stdout, console.Info+"No loot 🙁\n") @@ -213,6 +215,7 @@ func PrintAllFileLootTable(stdout io.Writer, allLoot *clientpb.AllLoot) { fmt.Fprintf(stdout, outputBuf.String()) } +// PrintAllCredentialLootTable - Displays a table of all credential loot func PrintAllCredentialLootTable(stdout io.Writer, allLoot *clientpb.AllLoot) { if allLoot == nil || len(allLoot.Loot) == 0 { fmt.Fprintf(stdout, console.Info+"No loot 🙁\n") @@ -263,58 +266,6 @@ func PrintAllCredentialLootTable(stdout io.Writer, allLoot *clientpb.AllLoot) { fmt.Fprintf(stdout, outputBuf.String()) } -func SelectLoot(ctx *grumble.Context, rpc rpcpb.SliverRPCClient) (*clientpb.Loot, error) { - - // Fetch data with optional filter - filter := ctx.Flags.String("filter") - var allLoot *clientpb.AllLoot - var err error - if filter == "" { - allLoot, err = rpc.LootAll(context.Background(), &commonpb.Empty{}) - if err != nil { - return nil, err - } - } else { - lootType, err := lootTypeFromHumanStr(filter) - if err != nil { - return nil, ErrInvalidFileType - } - allLoot, err = rpc.LootAllOf(context.Background(), &clientpb.Loot{Type: lootType}) - if err != nil { - return nil, err - } - } - - // Render selection table - buf := bytes.NewBufferString("") - table := tabwriter.NewWriter(buf, 0, 2, 2, ' ', 0) - for _, loot := range allLoot.Loot { - fmt.Fprintf(table, "%s\t%s\t%s\t\n", loot.Name, loot.Type, loot.LootID) - } - table.Flush() - options := strings.Split(buf.String(), "\n") - options = options[:len(options)-1] - if len(options) == 0 { - return nil, errors.New("no loot to select from") - } - - selected := "" - prompt := &survey.Select{ - Message: "Select a piece of loot:", - Options: options, - } - err = survey.AskOne(prompt, &selected) - if err != nil { - return nil, err - } - for index, value := range options { - if value == selected { - return allLoot.Loot[index], nil - } - } - return nil, errors.New("loot not found") -} - func lootTypeToStr(value clientpb.LootType) string { switch value { case clientpb.LootType_LOOT_FILE: diff --git a/client/command/monitor/start.go b/client/command/monitor/start.go index 40bd9b57a7..58e838c58a 100644 --- a/client/command/monitor/start.go +++ b/client/command/monitor/start.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// MonitorStartCmd - Start monitoring threat intel for implants func MonitorStartCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { resp, err := con.Rpc.MonitorStart(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/monitor/stop.go b/client/command/monitor/stop.go index ea8ef8f87c..5a0c2cf766 100644 --- a/client/command/monitor/stop.go +++ b/client/command/monitor/stop.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// MonitorStopCmd - Stop monitoring threat intel for implants func MonitorStopCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { _, err := con.Rpc.MonitorStop(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/network/ifconfig.go b/client/command/network/ifconfig.go index c33feb1d2e..07bd0ef25e 100644 --- a/client/command/network/ifconfig.go +++ b/client/command/network/ifconfig.go @@ -29,6 +29,7 @@ import ( "github.com/bishopfox/sliver/protobuf/sliverpb" ) +// IfconfigCmd - Display network interfaces on the remote system func IfconfigCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/network/netstat.go b/client/command/network/netstat.go index 397ee3a87d..e563d6f3c6 100644 --- a/client/command/network/netstat.go +++ b/client/command/network/netstat.go @@ -29,6 +29,7 @@ import ( "github.com/desertbit/grumble" ) +// NetstatCmd - Display active network connections on the remote system func NetstatCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/operators/operators.go b/client/command/operators/operators.go index d86c8a1346..afedfd24a9 100644 --- a/client/command/operators/operators.go +++ b/client/command/operators/operators.go @@ -32,6 +32,7 @@ import ( "github.com/desertbit/grumble" ) +// OperatorsCmd - Display operators and current online status func OperatorsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { operators, err := con.Rpc.GetOperators(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/pivots/named-pipe.go b/client/command/pivots/named-pipe.go index 60c9b8423c..38ad14f8d3 100644 --- a/client/command/pivots/named-pipe.go +++ b/client/command/pivots/named-pipe.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// NamedPipeListenerCmd - Start a named pipe pivot listener on the remote system func NamedPipeListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/pivots/pivots.go b/client/command/pivots/pivots.go index 8e61ab565c..7798af47b7 100644 --- a/client/command/pivots/pivots.go +++ b/client/command/pivots/pivots.go @@ -33,6 +33,7 @@ import ( "github.com/desertbit/grumble" ) +// PivotsCmd - Display pivots for all sessions func PivotsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { timeout := ctx.Flags.Int("timeout") sessionID := ctx.Flags.String("id") diff --git a/client/command/pivots/tcp.go b/client/command/pivots/tcp.go index 3f494f486b..a0452e21e7 100644 --- a/client/command/pivots/tcp.go +++ b/client/command/pivots/tcp.go @@ -9,6 +9,7 @@ import ( "github.com/desertbit/grumble" ) +// TCPListenerCmd - Start a TCP pivot listener on the remote system func TCPListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/portfwd/portfwd-add.go b/client/command/portfwd/portfwd-add.go index 439a8371b9..2ef4f574d2 100644 --- a/client/command/portfwd/portfwd-add.go +++ b/client/command/portfwd/portfwd-add.go @@ -29,6 +29,7 @@ import ( "github.com/desertbit/grumble" ) +// PortfwdAddCmd - Add a new tunneled port forward func PortfwdAddCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/portfwd/portfwd-rm.go b/client/command/portfwd/portfwd-rm.go index 9bde2a4759..29f27fa3b0 100644 --- a/client/command/portfwd/portfwd-rm.go +++ b/client/command/portfwd/portfwd-rm.go @@ -24,6 +24,7 @@ import ( "github.com/desertbit/grumble" ) +// PortfwdRmCmd - Remove an existing tunneled port forward func PortfwdRmCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { portfwdID := ctx.Flags.Int("id") if portfwdID < 1 { diff --git a/client/command/portfwd/portfwd.go b/client/command/portfwd/portfwd.go index 38fa9bac91..8689ba83c1 100644 --- a/client/command/portfwd/portfwd.go +++ b/client/command/portfwd/portfwd.go @@ -30,6 +30,7 @@ import ( "github.com/desertbit/grumble" ) +// PortfwdCmd - Display information about tunneled port forward(s) func PortfwdCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { portfwds := core.Portfwds.List() if len(portfwds) == 0 { diff --git a/client/command/privilege/getsystem.go b/client/command/privilege/getsystem.go index 35e43e2df3..dc01dfe562 100644 --- a/client/command/privilege/getsystem.go +++ b/client/command/privilege/getsystem.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// GetSystemCmd - Windows only, attempt to get SYSTEM on the remote system func GetSystemCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/privilege/impersonate.go b/client/command/privilege/impersonate.go index b18480b822..9336982ef9 100644 --- a/client/command/privilege/impersonate.go +++ b/client/command/privilege/impersonate.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// ImpersonateCmd - Windows only, impersonate a user token func ImpersonateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/privilege/make-token.go b/client/command/privilege/make-token.go index fec0190cff..ad2a7f93bf 100644 --- a/client/command/privilege/make-token.go +++ b/client/command/privilege/make-token.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// MakeTokenCmd - Windows only, create a token using "valid" credentails func MakeTokenCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/privilege/rev2self.go b/client/command/privilege/rev2self.go index ec2db50cc5..27f392ad36 100644 --- a/client/command/privilege/rev2self.go +++ b/client/command/privilege/rev2self.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// RevToSelfCmd - Drop any impersonated tokens func RevToSelfCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/privilege/runas.go b/client/command/privilege/runas.go index 337e71ad9e..adf0ffb2c7 100644 --- a/client/command/privilege/runas.go +++ b/client/command/privilege/runas.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// RunAsCmd - Run a command as another user on the remote system func RunAsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/processes/procdump.go b/client/command/processes/procdump.go index a0533ca699..17e3bcb7a0 100644 --- a/client/command/processes/procdump.go +++ b/client/command/processes/procdump.go @@ -11,6 +11,7 @@ import ( "github.com/desertbit/grumble" ) +// ProcdumpCmd - Dump the memory of a remote process func ProcdumpCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/processes/ps.go b/client/command/processes/ps.go index 25e4fe20d8..8978eb8332 100644 --- a/client/command/processes/ps.go +++ b/client/command/processes/ps.go @@ -44,6 +44,7 @@ var ( } ) +// PsCmd - List processes on the remote system func PsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/processes/terminate.go b/client/command/processes/terminate.go index 8f8cca8284..0c35fdf8a0 100644 --- a/client/command/processes/terminate.go +++ b/client/command/processes/terminate.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// TerminateCmd - Terminate a process on the remote system func TerminateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/registry/reg-create.go b/client/command/registry/reg-create.go index aeea35637e..8ef88ceadf 100644 --- a/client/command/registry/reg-create.go +++ b/client/command/registry/reg-create.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// RegCreateKeyCmd - Create a new Windows registry key func RegCreateKeyCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/registry/reg-read.go b/client/command/registry/reg-read.go index 0b149c2beb..aa8bf780c7 100644 --- a/client/command/registry/reg-read.go +++ b/client/command/registry/reg-read.go @@ -70,7 +70,7 @@ func getType(t string) (uint32, error) { return res, nil } -// registry read --hostname aa.bc.local --hive HKCU "software\google\chrome\blbeacon\version" +// RegReadCmd - Read a windows registry key: registry read --hostname aa.bc.local --hive HKCU "software\google\chrome\blbeacon\version" func RegReadCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/registry/reg-write.go b/client/command/registry/reg-write.go index dcc4367eba..82ed5125a9 100644 --- a/client/command/registry/reg-write.go +++ b/client/command/registry/reg-write.go @@ -30,7 +30,7 @@ import ( "github.com/desertbit/grumble" ) -// registry write --hive HKCU --type dword "software\google\chrome\blbeacon\hello" 32 +// RegWriteCmd - Write to a Windows registry key: registry write --hive HKCU --type dword "software\google\chrome\blbeacon\hello" 32 func RegWriteCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/screenshot/screenshot.go b/client/command/screenshot/screenshot.go index ad84cc8175..3884b379ee 100644 --- a/client/command/screenshot/screenshot.go +++ b/client/command/screenshot/screenshot.go @@ -32,6 +32,7 @@ import ( "github.com/desertbit/grumble" ) +// ScreenshotCmd - Take a screenshot of the remote system func ScreenshotCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/sessions/background.go b/client/command/sessions/background.go index 3015c78a4d..0e8c5a0b9a 100644 --- a/client/command/sessions/background.go +++ b/client/command/sessions/background.go @@ -5,6 +5,7 @@ import ( "github.com/desertbit/grumble" ) +// BackgroundCmd - Background the active session func BackgroundCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { con.ActiveSession.Background() con.PrintInfof("Background ...\n") diff --git a/client/command/sessions/helpers.go b/client/command/sessions/helpers.go index 7e41774960..df881b4213 100644 --- a/client/command/sessions/helpers.go +++ b/client/command/sessions/helpers.go @@ -38,6 +38,7 @@ var ( ErrNoSelection = errors.New("no selection") ) +// SelectSession - Interactive menu for the user to select an session, optionally only display live sessions func SelectSession(onlyAlive bool, con *console.SliverConsoleClient) (*clientpb.Session, error) { sessions, err := con.Rpc.GetSessions(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/sessions/kill.go b/client/command/sessions/kill.go index e999f860ac..476db54dd9 100644 --- a/client/command/sessions/kill.go +++ b/client/command/sessions/kill.go @@ -12,6 +12,7 @@ import ( "gopkg.in/AlecAivazis/survey.v1" ) +// KillCmd - Kill the active session (not to be confused with TerminateCmd) func KillCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/sessions/prune.go b/client/command/sessions/prune.go index db679a57dc..96c8f3e817 100644 --- a/client/command/sessions/prune.go +++ b/client/command/sessions/prune.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// SessionsPruneCmd - Forcefully kill stale sessions func SessionsPruneCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { sessions, err := con.Rpc.GetSessions(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/sessions/reconfig.go b/client/command/sessions/reconfig.go index b9f1a3a193..1b8a4aca71 100644 --- a/client/command/sessions/reconfig.go +++ b/client/command/sessions/reconfig.go @@ -28,6 +28,7 @@ import ( "github.com/desertbit/grumble" ) +// SessionsReconfigCmd - Reconfigure metadata about a sessions func SessionsReconfigCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/sessions/sessions.go b/client/command/sessions/sessions.go index 14d9aa8e2b..b2ed5021b5 100644 --- a/client/command/sessions/sessions.go +++ b/client/command/sessions/sessions.go @@ -33,6 +33,7 @@ import ( "github.com/desertbit/grumble" ) +// SessionsCmd - Display/interact with sessions func SessionsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { interact := ctx.Flags.String("interact") diff --git a/client/command/sessions/use.go b/client/command/sessions/use.go index 541243052a..e52519caeb 100644 --- a/client/command/sessions/use.go +++ b/client/command/sessions/use.go @@ -6,6 +6,7 @@ import ( "github.com/desertbit/grumble" ) +// UseCmd - Change the active session func UseCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { sessionArg := ctx.Args.String("session") if sessionArg != "" { diff --git a/client/command/shell/shell.go b/client/command/shell/shell.go index a459828e2e..dbfd8e42c6 100644 --- a/client/command/shell/shell.go +++ b/client/command/shell/shell.go @@ -28,9 +28,9 @@ import ( "github.com/bishopfox/sliver/client/console" "github.com/bishopfox/sliver/client/core" "github.com/bishopfox/sliver/protobuf/sliverpb" + "golang.org/x/crypto/ssh/terminal" "github.com/desertbit/grumble" - "golang.org/x/crypto/ssh/terminal" ) const ( @@ -39,6 +39,7 @@ const ( linux = "linux" ) +// ShellCmd - Start an interactive shell on the remote system func ShellCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/update/update.go b/client/command/update/update.go index d665008956..30fb95b542 100644 --- a/client/command/update/update.go +++ b/client/command/update/update.go @@ -47,6 +47,7 @@ import ( "github.com/desertbit/grumble" ) +// UpdateCmd - Check for updates func UpdateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { VerboseVersionsCmd(ctx, con) @@ -124,6 +125,7 @@ func UpdateCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { } } +// VerboseVersionsCmd - Get verbose version information about the client and server func VerboseVersionsCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { clientVer := version.FullVersion() serverVer, err := con.Rpc.GetVersion(context.Background(), &commonpb.Empty{}) diff --git a/client/command/websites/websites-add-content.go b/client/command/websites/websites-add-content.go index 1e2d77f17d..9f4dd971cc 100644 --- a/client/command/websites/websites-add-content.go +++ b/client/command/websites/websites-add-content.go @@ -16,6 +16,7 @@ import ( "gopkg.in/AlecAivazis/survey.v1" ) +// WebsitesAddContentCmd - Add static content to a website func WebsitesAddContentCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { websiteName := ctx.Flags.String("website") if websiteName == "" { diff --git a/client/command/websites/websites-rm-content.go b/client/command/websites/websites-rm-content.go index 3c2e987815..d57e23e9c5 100644 --- a/client/command/websites/websites-rm-content.go +++ b/client/command/websites/websites-rm-content.go @@ -9,6 +9,7 @@ import ( "github.com/desertbit/grumble" ) +// WebsitesRmContent - Remove static content from a website func WebsitesRmContent(ctx *grumble.Context, con *console.SliverConsoleClient) { name := ctx.Flags.String("website") webPath := ctx.Flags.String("web-path") diff --git a/client/command/websites/websites-rm.go b/client/command/websites/websites-rm.go index bffbf74a6b..a0fca2eda8 100644 --- a/client/command/websites/websites-rm.go +++ b/client/command/websites/websites-rm.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// WebsiteRmCmd - Remove a website and all its static content func WebsiteRmCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { _, err := con.Rpc.WebsiteRemove(context.Background(), &clientpb.Website{ Name: ctx.Args.String("name"), diff --git a/client/command/websites/websites-update-content.go b/client/command/websites/websites-update-content.go index 72d01cee5d..33308c6bb1 100644 --- a/client/command/websites/websites-update-content.go +++ b/client/command/websites/websites-update-content.go @@ -8,6 +8,7 @@ import ( "github.com/desertbit/grumble" ) +// WebsitesUpdateContentCmd - Update metadata about static website content func WebsitesUpdateContentCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { websiteName := ctx.Flags.String("website") if websiteName == "" { diff --git a/client/command/websites/websites.go b/client/command/websites/websites.go index 486a0adefd..ffcb62af6d 100644 --- a/client/command/websites/websites.go +++ b/client/command/websites/websites.go @@ -37,6 +37,7 @@ const ( defaultMimeType = "application/octet-stream" ) +// WebsitesCmd - Manage websites func WebsitesCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { websiteName := ctx.Args.String("name") if websiteName == "" { @@ -46,6 +47,7 @@ func WebsitesCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { } } +// ListWebsites - Display a list of websites func ListWebsites(ctx *grumble.Context, con *console.SliverConsoleClient) { websites, err := con.Rpc.Websites(context.Background(), &commonpb.Empty{}) if err != nil { @@ -63,6 +65,7 @@ func ListWebsites(ctx *grumble.Context, con *console.SliverConsoleClient) { } } +// ListWebsiteContent - List the static contents of a website func ListWebsiteContent(websiteName string, con *console.SliverConsoleClient) { website, err := con.Rpc.Website(context.Background(), &clientpb.Website{ Name: websiteName, diff --git a/client/command/wireguard/wg-config.go b/client/command/wireguard/wg-config.go index 232089a21f..9b7ea1e9d9 100644 --- a/client/command/wireguard/wg-config.go +++ b/client/command/wireguard/wg-config.go @@ -51,6 +51,7 @@ type wgQuickConfig struct { AllowedSubnet string } +// WGConfigCmd - Generate a WireGuard client configuration func WGConfigCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { wgConfig, err := con.Rpc.GenerateWGClientConfig(context.Background(), &commonpb.Empty{}) if err != nil { diff --git a/client/command/wireguard/wg-portfwd-add.go b/client/command/wireguard/wg-portfwd-add.go index 139ed548d7..a22679a219 100644 --- a/client/command/wireguard/wg-portfwd-add.go +++ b/client/command/wireguard/wg-portfwd-add.go @@ -27,6 +27,7 @@ import ( "github.com/desertbit/grumble" ) +// WGPortFwdAddCmd - Add a new WireGuard port forward func WGPortFwdAddCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/wireguard/wg-portfwd-rm.go b/client/command/wireguard/wg-portfwd-rm.go index 67c4d14eb1..e30b344fd6 100644 --- a/client/command/wireguard/wg-portfwd-rm.go +++ b/client/command/wireguard/wg-portfwd-rm.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// WGPortFwdRmCmd - Remove a WireGuard port forward func WGPortFwdRmCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/wireguard/wg-portfwd.go b/client/command/wireguard/wg-portfwd.go index 63afd55cef..cfd58fe33d 100644 --- a/client/command/wireguard/wg-portfwd.go +++ b/client/command/wireguard/wg-portfwd.go @@ -30,6 +30,7 @@ import ( "github.com/desertbit/grumble" ) +// WGPortFwdListCmd - List WireGuard port forwards func WGPortFwdListCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/wireguard/wg-socks-start.go b/client/command/wireguard/wg-socks-start.go index 4952cd6748..39fb9cf9ec 100644 --- a/client/command/wireguard/wg-socks-start.go +++ b/client/command/wireguard/wg-socks-start.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// WGSocksStartCmd - Start a WireGuard reverse SOCKS proxy func WGSocksStartCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { diff --git a/client/command/wireguard/wg-socks-stop.go b/client/command/wireguard/wg-socks-stop.go index 96605b3ac3..bef8d81e6b 100644 --- a/client/command/wireguard/wg-socks-stop.go +++ b/client/command/wireguard/wg-socks-stop.go @@ -26,6 +26,7 @@ import ( "github.com/desertbit/grumble" ) +// WGSocksStopCmd - Stop a WireGuard SOCKS proxy func WGSocksStopCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.Get() if session == nil { diff --git a/client/command/wireguard/wg-socks.go b/client/command/wireguard/wg-socks.go index 4fa7f72205..13577d83ad 100644 --- a/client/command/wireguard/wg-socks.go +++ b/client/command/wireguard/wg-socks.go @@ -30,6 +30,7 @@ import ( "github.com/desertbit/grumble" ) +// WGSocksListCmd - List WireGuard SOCKS proxies func WGSocksListCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { session := con.ActiveSession.GetInteractive() if session == nil { From b80044867093d6a8479542b317cef9fc21a82fa1 Mon Sep 17 00:00:00 2001 From: moloch-- <875022+moloch--@users.noreply.github.com> Date: Sun, 4 Jul 2021 13:17:18 -0500 Subject: [PATCH 3/5] golint fixes in server/ --- server/configs/database.go | 2 +- server/configs/server.go | 4 ++++ server/db/models/wgkeys.go | 1 + server/loot/backend.go | 11 ++++++++++- server/loot/loot.go | 19 ++++++++++++------- server/rpc/rpc-shell.go | 4 ++-- server/rpc/rpc-tunnel.go | 4 ++-- 7 files changed, 32 insertions(+), 13 deletions(-) diff --git a/server/configs/database.go b/server/configs/database.go index c896531612..8600d3bead 100644 --- a/server/configs/database.go +++ b/server/configs/database.go @@ -43,7 +43,7 @@ const ( ) var ( - // ErrInvalidDialect - + // ErrInvalidDialect - An invalid dialect was specified ErrInvalidDialect = errors.New("Invalid SQL Dialect") databaseConfigLog = log.NamedLogger("config", "database") diff --git a/server/configs/server.go b/server/configs/server.go index e0d5f457bf..9f9fbbef97 100644 --- a/server/configs/server.go +++ b/server/configs/server.go @@ -83,6 +83,8 @@ type WGJobConfig struct { KeyPort uint16 `json:"key_port"` JobID string `json:"jobid"` } + +// DNSJobConfig - Persistent DNS job config type DNSJobConfig struct { Domains []string `json:"domains"` Canaries bool `json:"canaries"` @@ -91,6 +93,7 @@ type DNSJobConfig struct { JobID string `json:"jobid"` } +// HTTPJobConfig - Persistent HTTP job config type HTTPJobConfig struct { Domain string `json:"domain"` Host string `json:"host"` @@ -103,6 +106,7 @@ type HTTPJobConfig struct { JobID string `json:"jobid"` } +// WatchTowerConfig - Watch Tower job config type WatchTowerConfig struct { VTApiKey string `json:"vt_api_key"` XForceApiKey string `json:"xforce_api_key"` diff --git a/server/db/models/wgkeys.go b/server/db/models/wgkeys.go index 5aec23d993..1a63f05019 100644 --- a/server/db/models/wgkeys.go +++ b/server/db/models/wgkeys.go @@ -26,6 +26,7 @@ func (c *WGKeys) BeforeCreate(tx *gorm.DB) (err error) { return nil } +// WGPeer- WGPeer database model type WGPeer struct { // gorm.Model ID uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"` diff --git a/server/loot/backend.go b/server/loot/backend.go index 7aa51654af..ebbc076d94 100644 --- a/server/loot/backend.go +++ b/server/loot/backend.go @@ -34,17 +34,21 @@ import ( ) var ( + // ErrInvalidLootID - Invalid Loot ID ErrInvalidLootID = errors.New("invalid loot id") - ErrLootNotFound = errors.New("loot not found") + // ErrLootNotFound - Loot not found + ErrLootNotFound = errors.New("loot not found") lootLog = log.NamedLogger("loot", "backend") ) +// LocalBackend - A loot backend that saves files locally to disk type LocalBackend struct { LocalFileDir string LocalCredDir string } +// Add - Add a piece of loot func (l *LocalBackend) Add(loot *clientpb.Loot) (*clientpb.Loot, error) { dbLoot := &models.Loot{ Name: loot.GetName(), @@ -90,6 +94,7 @@ func (l *LocalBackend) Add(loot *clientpb.Loot) (*clientpb.Loot, error) { return loot, err } +// Update - Update metadata about loot, currently only 'name' can be changed func (l *LocalBackend) Update(lootReq *clientpb.Loot) (*clientpb.Loot, error) { dbSession := db.Session() lootUUID, err := uuid.FromString(lootReq.LootID) @@ -112,6 +117,7 @@ func (l *LocalBackend) Update(lootReq *clientpb.Loot) (*clientpb.Loot, error) { return l.GetContent(lootReq.LootID, false) } +// Rm - Remove a piece of loot func (l *LocalBackend) Rm(lootID string) error { dbSession := db.Session() lootUUID, err := uuid.FromString(lootID) @@ -146,6 +152,7 @@ func (l *LocalBackend) Rm(lootID string) error { return result.Error } +// GetContent - Get the content of a piece of loot func (l *LocalBackend) GetContent(lootID string, eager bool) (*clientpb.Loot, error) { dbSession := db.Session() lootUUID, err := uuid.FromString(lootID) @@ -198,6 +205,7 @@ func (l *LocalBackend) GetContent(lootID string, eager bool) (*clientpb.Loot, er return loot, nil } +// All - Get all loot func (l *LocalBackend) All() *clientpb.AllLoot { dbSession := db.Session() allDBLoot := []*models.Loot{} @@ -221,6 +229,7 @@ func (l *LocalBackend) All() *clientpb.AllLoot { return all } +// AllOf - Get all loot of a particular loot type func (l *LocalBackend) AllOf(lootType clientpb.LootType) *clientpb.AllLoot { dbSession := db.Session() allDBLoot := []*models.Loot{} diff --git a/server/loot/loot.go b/server/loot/loot.go index 64a5d6f296..43d30670a9 100644 --- a/server/loot/loot.go +++ b/server/loot/loot.go @@ -31,6 +31,7 @@ const ( MaxLootSize = 2 * 1024 * 1024 * 1024 // 2Gb, shouldn't matter the gRPC message size limit is 2Gb ) +// LootBackend - The interface any loot backend must implement type LootBackend interface { Add(*clientpb.Loot) (*clientpb.Loot, error) Rm(string) error @@ -40,11 +41,12 @@ type LootBackend interface { AllOf(clientpb.LootType) *clientpb.AllLoot } +// LootStore - The struct that represents the loot store type LootStore struct { backend LootBackend - mirrors []LootBackend } +// Add - Add a piece of loot to the loot store func (l *LootStore) Add(lootReq *clientpb.Loot) (*clientpb.Loot, error) { if lootReq.File != nil && MaxLootSize < len(lootReq.File.Data) { return nil, errors.New("max loot size exceeded") @@ -53,12 +55,10 @@ func (l *LootStore) Add(lootReq *clientpb.Loot) (*clientpb.Loot, error) { if err != nil { return nil, err } - for _, mirror := range l.mirrors { - mirror.Add(loot) - } return loot, nil } +// Update - Update a piece of loot in the loot store func (l *LootStore) Update(lootReq *clientpb.Loot) (*clientpb.Loot, error) { loot, err := l.backend.Update(lootReq) if err != nil { @@ -67,29 +67,31 @@ func (l *LootStore) Update(lootReq *clientpb.Loot) (*clientpb.Loot, error) { return loot, nil } +// Remove - Remove a piece of loot from the loot store func (l *LootStore) Rm(lootID string) error { err := l.backend.Rm(lootID) if err != nil { return err } - for _, mirror := range l.mirrors { - mirror.Rm(lootID) - } return nil } +// GetContent - Get the content of a piece of loot from the loot store func (l *LootStore) GetContent(lootID string, eager bool) (*clientpb.Loot, error) { return l.backend.GetContent(lootID, eager) } +// All - Get all loot from the loot store func (l *LootStore) All() *clientpb.AllLoot { return l.backend.All() } +// AllOf - Get loot of a particular type from the loot store func (l *LootStore) AllOf(lootType clientpb.LootType) *clientpb.AllLoot { return l.backend.AllOf(lootType) } +// GetLootStore - Get an instances of the core LootStore func GetLootStore() *LootStore { return &LootStore{ backend: &LocalBackend{ @@ -99,6 +101,7 @@ func GetLootStore() *LootStore { } } +// GetLootDir - Get the directory that contains all loot func GetLootDir() string { lootDir := filepath.Join(assets.GetRootAppDir(), "loot") if _, err := os.Stat(lootDir); os.IsNotExist(err) { @@ -110,6 +113,7 @@ func GetLootDir() string { return lootDir } +// GetLootFileDir - Get the subdirectory where loot files are stored func GetLootFileDir() string { lootFileDir := filepath.Join(GetLootDir(), "files") if _, err := os.Stat(lootFileDir); os.IsNotExist(err) { @@ -121,6 +125,7 @@ func GetLootFileDir() string { return lootFileDir } +// GetLootCredentialDir - Get the subdirectory where loot credentials are stored func GetLootCredentialDir() string { lootCredDir := filepath.Join(GetLootDir(), "credentials") if _, err := os.Stat(lootCredDir); os.IsNotExist(err) { diff --git a/server/rpc/rpc-shell.go b/server/rpc/rpc-shell.go index c5dd02377e..29105ee20d 100644 --- a/server/rpc/rpc-shell.go +++ b/server/rpc/rpc-shell.go @@ -33,7 +33,7 @@ var ( ) // Shell - Open an interactive shell -func (s *Server) Shell(ctx context.Context, req *sliverpb.ShellReq) (*sliverpb.Shell, error) { +func (rpc *Server) Shell(ctx context.Context, req *sliverpb.ShellReq) (*sliverpb.Shell, error) { session := core.Sessions.Get(req.Request.SessionID) if session == nil { return nil, ErrInvalidSessionID @@ -46,7 +46,7 @@ func (s *Server) Shell(ctx context.Context, req *sliverpb.ShellReq) (*sliverpb.S if err != nil { return nil, err } - data, err := session.Request(sliverpb.MsgNumber(req), s.getTimeout(req), reqData) + data, err := session.Request(sliverpb.MsgNumber(req), rpc.getTimeout(req), reqData) if err != nil { return nil, err } diff --git a/server/rpc/rpc-tunnel.go b/server/rpc/rpc-tunnel.go index e111d40b1a..2318945d53 100644 --- a/server/rpc/rpc-tunnel.go +++ b/server/rpc/rpc-tunnel.go @@ -170,7 +170,7 @@ func (s *Server) TunnelData(stream rpcpb.SliverRPC_TunnelDataServer) error { go func() { session := core.Sessions.Get(tunnel.SessionID) - send_cache, _ := toImplantCache[tunnel.ID] + sendCache, _ := toImplantCache[tunnel.ID] for data := range tunnel.ToImplant { tunnelLog.Debugf("Tunnel %d: To implant %d byte(s), seq: %d", tunnel.ID, len(data), tunnel.ToImplantSequence) tunnelData := sliverpb.TunnelData{ @@ -181,7 +181,7 @@ func (s *Server) TunnelData(stream rpcpb.SliverRPC_TunnelDataServer) error { Closed: false, } // Add tunnel data to cache - send_cache[tunnelData.Sequence] = &tunnelData + sendCache[tunnelData.Sequence] = &tunnelData data, _ := proto.Marshal(&tunnelData) tunnel.ToImplantSequence++ From cee5966e77000e6556816866067566fc693c8d10 Mon Sep 17 00:00:00 2001 From: moloch-- <875022+moloch--@users.noreply.github.com> Date: Sun, 4 Jul 2021 13:19:53 -0500 Subject: [PATCH 4/5] golint fixes in client/core --- client/core/portfwd.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/core/portfwd.go b/client/core/portfwd.go index 1ed2db923a..e7bd4d309c 100644 --- a/client/core/portfwd.go +++ b/client/core/portfwd.go @@ -18,6 +18,7 @@ import ( ) var ( + // Portfwds - Struct instance that holds all the portfwds Portfwds = portfwds{ forwards: map[int]*Portfwd{}, mutex: &sync.RWMutex{}, @@ -41,6 +42,7 @@ type Portfwd struct { ChannelProxy *ChannelProxy } +// GetMetadata - Get metadata about the portfwd func (p *Portfwd) GetMetadata() *PortfwdMeta { return &PortfwdMeta{ ID: p.ID, @@ -55,6 +57,7 @@ type portfwds struct { mutex *sync.RWMutex } +// Add - Add a TCP proxy instance func (f *portfwds) Add(tcpProxy *tcpproxy.Proxy, channelProxy *ChannelProxy) *Portfwd { f.mutex.Lock() defer f.mutex.Unlock() @@ -67,6 +70,7 @@ func (f *portfwds) Add(tcpProxy *tcpproxy.Proxy, channelProxy *ChannelProxy) *Po return portfwd } +// Remove - Remove a TCP proxy instance func (f *portfwds) Remove(portfwdID int) bool { f.mutex.Lock() defer f.mutex.Unlock() @@ -78,6 +82,7 @@ func (f *portfwds) Remove(portfwdID int) bool { return false } +// List - List all TCP proxy instances func (f *portfwds) List() []*PortfwdMeta { f.mutex.RLock() defer f.mutex.RUnlock() @@ -102,6 +107,7 @@ type ChannelProxy struct { DialTimeout time.Duration } +// HandleConn - Handle a TCP connection func (p *ChannelProxy) HandleConn(conn net.Conn) { log.Printf("[tcpproxy] Handling new connection") ctx := context.Background() @@ -134,6 +140,7 @@ func (p *ChannelProxy) HandleConn(conn net.Conn) { } } +// HostPort - Returns the host and port of the TCP proxy func (p *ChannelProxy) HostPort() (string, uint32) { defaultPort := uint32(8080) host, rawPort, err := net.SplitHostPort(p.RemoteAddr) @@ -154,11 +161,13 @@ func (p *ChannelProxy) HostPort() (string, uint32) { return host, port } +// Port - Returns the TCP port of the proxy func (p *ChannelProxy) Port() uint32 { _, port := p.HostPort() return port } +// Host - Returns the host (i.e., interface) of the TCP proxy func (p *ChannelProxy) Host() string { host, _ := p.HostPort() return host From 7321f62778648b62bdc580fb0a1a4168396c7407 Mon Sep 17 00:00:00 2001 From: moloch-- <875022+moloch--@users.noreply.github.com> Date: Sun, 4 Jul 2021 13:22:27 -0500 Subject: [PATCH 5/5] golint fixes in server/generate --- server/generate/binaries.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/generate/binaries.go b/server/generate/binaries.go index 1ce7cd099c..13d8cb9f0b 100644 --- a/server/generate/binaries.go +++ b/server/generate/binaries.go @@ -113,6 +113,7 @@ const ( DefaultSuffix = "_default.go" // *** Default *** + // SliverCC64EnvVar - Environment variable that can specify the 64 bit mingw path SliverCC64EnvVar = "SLIVER_CC_64" // SliverCC32EnvVar - Environment variable that can specify the 32 bit mingw path @@ -124,6 +125,7 @@ const ( SliverCXX32EnvVar = "SLIVER_CXX_32" // *** Platform Specific *** + // SliverPlatformCC64EnvVar - Environment variable that can specify the 64 bit mingw path SliverPlatformCC64EnvVar = "SLIVER_%s_CC_64" // SliverPlatformCC32EnvVar - Environment variable that can specify the 32 bit mingw path @@ -721,7 +723,7 @@ func getCrossCompilers(targetGoos string, targetGoarch string) (string, string) return cc, cxx } -// This function attempts to determine what we can reasonably target +// GetCompilerTargets - This function attempts to determine what we can reasonably target func GetCompilerTargets() []*clientpb.CompilerTarget { targets := []*clientpb.CompilerTarget{} @@ -797,6 +799,7 @@ func GetCompilerTargets() []*clientpb.CompilerTarget { return targets } +// GetCrossCompilers - Get information about the server's cross-compiler configuration func GetCrossCompilers() []*clientpb.CrossCompiler { compilers := []*clientpb.CrossCompiler{} for longPlatform := range SupportedCompilerTargets { @@ -817,6 +820,7 @@ func GetCrossCompilers() []*clientpb.CrossCompiler { return compilers } +// GetUnsupportedTargets - Get compiler targets that are not "supported" on this platform func GetUnsupportedTargets() []*clientpb.CompilerTarget { appDir := assets.GetRootAppDir() distList := gogo.GoToolDistList(gogo.GoConfig{