Scan commands

Added 3 scan commands (internet, protocols and submit).
This commit is contained in:
perp 2023-08-02 04:56:39 +01:00
parent 07c61c1b1c
commit 76c9f54129
4 changed files with 107 additions and 0 deletions

View File

@ -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 <port> <protocol>",
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])
},
}

View File

@ -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()
},
}

View File

@ -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)
}

View File

@ -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 <host>\nsubmit <host-1> <host-2>...",
Args: cobra.MinimumNArgs(1),
Run: func(_ *cobra.Command, args []string) {
utils.CheckColor()
scan.Submit(args)
},
}