diff --git a/cmd/shogo/commands/scan/internet.go b/cmd/shogo/commands/scan/internet.go new file mode 100644 index 0000000..37349a5 --- /dev/null +++ b/cmd/shogo/commands/scan/internet.go @@ -0,0 +1,31 @@ +package scan + +import ( + "fmt" + "os" + "strconv" + + "github.com/spf13/cobra" + + "git.tcp.direct/perp/shogo/internal/shodan/scan" + "git.tcp.direct/perp/shogo/internal/utils" +) + +// Internet command +var internetCmd = &cobra.Command{ + Use: "internet", + Short: "Submit an internet scan", + Example: "internet ", + Args: cobra.MinimumNArgs(2), + Run: func(_ *cobra.Command, args []string) { + utils.CheckColor() + + // Convert string to int + port, err := strconv.Atoi(args[0]) + if err != nil { + fmt.Printf("%s: %s\n", utils.Red("Error"), err.Error()) + os.Exit(1) + } + scan.Internet(port, args[1]) + }, +} diff --git a/cmd/shogo/commands/scan/protocols.go b/cmd/shogo/commands/scan/protocols.go new file mode 100644 index 0000000..ac775cc --- /dev/null +++ b/cmd/shogo/commands/scan/protocols.go @@ -0,0 +1,18 @@ +package scan + +import ( + "github.com/spf13/cobra" + + "git.tcp.direct/perp/shogo/internal/shodan/scan" + "git.tcp.direct/perp/shogo/internal/utils" +) + +// Protocols command +var protocolsCmd = &cobra.Command{ + Use: "protocols", + Short: "Return protocols to scan", + Run: func(_ *cobra.Command, _ []string) { + utils.CheckColor() + scan.Protocols() + }, +} diff --git a/cmd/shogo/commands/scan/scan.go b/cmd/shogo/commands/scan/scan.go new file mode 100644 index 0000000..0062c48 --- /dev/null +++ b/cmd/shogo/commands/scan/scan.go @@ -0,0 +1,38 @@ +package scan + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" + + "git.tcp.direct/perp/shogo/internal/utils" +) + +// Global flags +var noColor bool + +// Scan command +var ScanCmd = &cobra.Command{ + Use: "scan", + Short: "Scan an IP/netblock", + Run: func(cmd *cobra.Command, _ []string) { + utils.CheckColor() + if err := cmd.Help(); err != nil { + fmt.Printf("%s: %s\n", utils.Red("Error"), err.Error()) + os.Exit(1) + } + }, +} + +func init() { + // Add flags + ScanCmd.PersistentFlags().BoolVar(&utils.Disabled, "no-color", false, "Disable color output") + ScanCmd.Flags().SortFlags = false + cobra.EnableCommandSorting = false + + // Add commands + ScanCmd.AddCommand(internetCmd) + ScanCmd.AddCommand(protocolsCmd) + ScanCmd.AddCommand(submitCmd) +} diff --git a/cmd/shogo/commands/scan/submit.go b/cmd/shogo/commands/scan/submit.go new file mode 100644 index 0000000..31bf3cb --- /dev/null +++ b/cmd/shogo/commands/scan/submit.go @@ -0,0 +1,20 @@ +package scan + +import ( + "github.com/spf13/cobra" + + "git.tcp.direct/perp/shogo/internal/shodan/scan" + "git.tcp.direct/perp/shogo/internal/utils" +) + +// Submit command +var submitCmd = &cobra.Command{ + Use: "submit", + Short: "Submit a scan", + Example: "submit \nsubmit ...", + Args: cobra.MinimumNArgs(1), + Run: func(_ *cobra.Command, args []string) { + utils.CheckColor() + scan.Submit(args) + }, +}