Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the services command #1557

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/command/help/long-help.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var (
consts.SSHStr: sshHelp,
consts.DLLHijackStr: dllHijackHelp,
consts.GetPrivsStr: getPrivsHelp,
consts.ServicesStr: servicesHelp,

// Loot
consts.LootStr: lootHelp,
Expand Down Expand Up @@ -1293,6 +1294,11 @@ Searches can be filtered using the following patterns:
If you need to match a special character (*, ?, '-', '[', ']', '\\'), place '\\' in front of it (example: \\?).
On Windows, escaping is disabled. Instead, '\\' is treated as path separator.`

servicesHelp = `[[.Bold]]Command:[[.Normal]] services [-H <hostname>]
[[.Bold]]About:[[.Normal]] Get information about services and control them (start, stop).
To get information about services, you need to be an authenticated user on the system or domain. To control services, you need administrator or higher privileges.`
)

const (
Expand Down
62 changes: 61 additions & 1 deletion client/command/processes/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,65 @@ func Commands(con *console.SliverClient) []*cobra.Command {
})
carapace.Gen(terminateCmd).PositionalCompletion(carapace.ActionValues().Usage("process ID"))

return []*cobra.Command{psCmd, procdumpCmd, terminateCmd}
servicesCmd := &cobra.Command{
Use: consts.ServicesStr,
Short: "Service operations",
Long: help.GetHelpFor([]string{consts.ServicesStr}),
Run: func(cmd *cobra.Command, args []string) {
ServicesCmd(cmd, con, args)
},
GroupID: consts.ProcessHelpGroup,
Annotations: flags.RestrictTargets(consts.WindowsCmdsFilter),
}
flags.Bind("", false, servicesCmd, func(f *pflag.FlagSet) {
f.StringP("host", "H", "localhost", "Hostname to retrieve service information from")
f.Int64P("timeout", "t", flags.DefaultTimeout, "grpc timeout in seconds")
})

serviceInfoCmd := &cobra.Command{
Use: consts.ServicesInfoStr,
Short: "Get detailed information about a single service",
Long: help.GetHelpFor([]string{consts.ServicesStr}),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
ServiceInfoCmd(cmd, con, args)
},
}
flags.Bind("", false, serviceInfoCmd, func(f *pflag.FlagSet) {
f.StringP("host", "H", "localhost", "Hostname to retrieve service information from")
f.Int64P("timeout", "t", flags.DefaultTimeout, "grpc timeout in seconds")
})
servicesCmd.AddCommand(serviceInfoCmd)

serviceStopCmd := &cobra.Command{
Use: consts.ServicesStopStr,
Short: "Stop a service on the local machine or a remote machine",
Long: help.GetHelpFor([]string{consts.ServicesStr}),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
ServiceStopCmd(cmd, con, args)
},
}
flags.Bind("", false, serviceStopCmd, func(f *pflag.FlagSet) {
f.StringP("host", "H", "localhost", "Hostname to stop service on")
f.Int64P("timeout", "t", flags.DefaultTimeout, "grpc timeout in seconds")
})
servicesCmd.AddCommand(serviceStopCmd)

serviceStartCmd := &cobra.Command{
Use: consts.ServicesStartStr,
Short: "Start a service on the local machine or a remote machine",
Long: help.GetHelpFor([]string{consts.ServicesStr}),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
ServiceStartCmd(cmd, con, args)
},
}
flags.Bind("", false, serviceStartCmd, func(f *pflag.FlagSet) {
f.StringP("host", "H", "localhost", "Hostname to start service on")
f.Int64P("timeout", "t", flags.DefaultTimeout, "grpc timeout in seconds")
})
servicesCmd.AddCommand(serviceStartCmd)

return []*cobra.Command{psCmd, procdumpCmd, terminateCmd, servicesCmd}
}
Loading
Loading