diff options
Diffstat (limited to 'cmd/root.go')
-rw-r--r-- | cmd/root.go | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/cmd/root.go b/cmd/root.go index 00563c6..473f1ad 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -3,7 +3,7 @@ package cmd import ( "context" "fmt" - "github.com/bryanmcnulty/adauth" + "github.com/RedTeamPentesting/adauth" "github.com/rs/zerolog" "github.com/spf13/cobra" "os" @@ -16,11 +16,28 @@ var ( ctx context.Context authOpts *adauth.Options - debug, trace bool + debug bool command string + executable string executablePath string executableArgs string + needsTarget = func(cmd *cobra.Command, args []string) (err error) { + if len(args) != 1 { + return fmt.Errorf("command require exactly one positional argument: [target]") + } + if creds, target, err = authOpts.WithTarget(ctx, "cifs", args[0]); err != nil { + return fmt.Errorf("failed to parse target: %w", err) + } + if creds == nil { + return fmt.Errorf("no credentials supplied") + } + if target == nil { + return fmt.Errorf("no target supplied") + } + return + } + rootCmd = &cobra.Command{ Use: "goexec", PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { @@ -42,13 +59,16 @@ func init() { rootCmd.InitDefaultVersionFlag() rootCmd.InitDefaultHelpCmd() - rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Enable debug logging") + rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable debug logging") authOpts = &adauth.Options{Debug: log.Debug().Msgf} authOpts.RegisterFlags(rootCmd.PersistentFlags()) scmrCmdInit() rootCmd.AddCommand(scmrCmd) + + tschCmdInit() + rootCmd.AddCommand(tschCmd) } func Execute() { |