✨ Scan commands
Added 3 scan commands (internet, protocols and submit).
This commit is contained in:
parent
07c61c1b1c
commit
76c9f54129
31
cmd/shogo/commands/scan/internet.go
Normal file
31
cmd/shogo/commands/scan/internet.go
Normal 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])
|
||||||
|
},
|
||||||
|
}
|
18
cmd/shogo/commands/scan/protocols.go
Normal file
18
cmd/shogo/commands/scan/protocols.go
Normal 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()
|
||||||
|
},
|
||||||
|
}
|
38
cmd/shogo/commands/scan/scan.go
Normal file
38
cmd/shogo/commands/scan/scan.go
Normal 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)
|
||||||
|
}
|
20
cmd/shogo/commands/scan/submit.go
Normal file
20
cmd/shogo/commands/scan/submit.go
Normal 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)
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user