Skip to content

Commit

Permalink
v1.0.X-remote
Browse files Browse the repository at this point in the history
  • Loading branch information
xfhg authored Oct 25, 2024
1 parent d627d76 commit 811737d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cmd/embed_remote_unavailable.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ var embeddedGossh embed.FS

var gosshPath string

var observeRemoteHost string = "0.0.0.0"
var observeRemotePort string = "23234"

func prepareGosshExecutable() (string, error) {
return "", nil
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/observe.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var (
observeList []string
observeConfig Config
observeRemote bool
observeRemotePort string = "23234"
observeRemoteHost string = "0.0.0.0"
)

var observeCmd = &cobra.Command{
Expand All @@ -60,6 +62,8 @@ func init() {
observeCmd.Flags().StringVar(&observeMode, "mode", "last", "Observe mode for path monitoring : first,last,all ")
observeCmd.Flags().StringVar(&observeIndex, "index", "intercept", "Index name for ES bulk operations")
observeCmd.Flags().BoolVar(&observeRemote, "remote", false, "Start SSH server for remote policy execution")
observeCmd.Flags().StringVar(&observeRemotePort, "remote-port", "23234", "Network port for remote policy execution")
observeCmd.Flags().StringVar(&observeRemoteHost, "remote-host", "0.0.0.0", "Network host bind for remote policy execution")

}

Expand Down
10 changes: 2 additions & 8 deletions cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ import (
"github.com/spf13/cobra"
)

// this is for --remote
const (
host = "0.0.0.0"
port = "23234"
)

var remote_users = map[string]string{}
var filteredPolicies []Policy

Expand Down Expand Up @@ -981,7 +975,7 @@ func startSSHServer(policies []Policy, outputDir string) error {
hostKeyPath := filepath.Join(outputDir, "_rpe/id_ed25519")

s, err := wish.NewServer(
wish.WithAddress(net.JoinHostPort(host, port)),
wish.WithAddress(net.JoinHostPort(observeRemoteHost, observeRemotePort)),
wish.WithHostKeyPath(hostKeyPath),
wish.WithBannerHandler(func(ctx ssh.Context) string {
return "\n\n┏━ INTERCEPT Remote Policy Execution Endpoint\n\n"
Expand All @@ -998,7 +992,7 @@ func startSSHServer(policies []Policy, outputDir string) error {
return fmt.Errorf("could not create server: %w", err)
}

log.Info().Str("host", host).Str("port", port).Msg("INTERCEPT Remote Policy Execution Endpoint")
log.Info().Str("host", observeRemoteHost).Str("port", observeRemotePort).Msg("INTERCEPT Remote Policy Execution Endpoint")
if err = s.ListenAndServe(); err != nil && !errors.Is(err, ssh.ErrServerClosed) {
return fmt.Errorf("could not start server: %w", err)
}
Expand Down

0 comments on commit 811737d

Please sign in to comment.