cmd

package
v0.0.0-...-397df0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HostDiscoveryCmd = &cobra.Command{
	Use:   util.HostDiscoveryName,
	Short: util.HDAppDescription,
	Run: func(cmd *cobra.Command, args []string) {

		targets, fileMode := util.ParseTargetInput(hostTarget)
		if len(targets) == 0 {
			log.Fatal().Msgf("%s", util.ErrInvalidTarget)
		}
		options := []string{}
		if hostCustomOptions != "" {
			options = strings.Fields(hostCustomOptions)

			for i, opt := range options {
				options[i] = strings.TrimSpace(opt)
			}
		}

		params := hostdiscovery.DiscoveryParams{
			Targets:    targets,
			OutputFile: hostOutputFile,
			Mode:       hostMode,
			Options:    options,
			FileMode:   fileMode,
		}

		strategy := hostdiscovery.NewNmapHostDiscovery()

		orchestrator := hostdiscovery.NewHostDiscoveryOrchestrator(strategy, params)

		fmt.Printf("%s Host Discovery", util.MarkerCyan)
		fmt.Printf("\n%s %s Starting\n", util.MarkerCyan, util.GetFormattedTime())
		hosts, err := orchestrator.Run()

		if err != nil {
			log.Fatal().Msgf("%s %v", util.FatalErrHD, err)
		}
		fmt.Printf("%s Discovered: %s %s\n", util.MarkerGreen, util.Green(strconv.Itoa(len(hosts))), util.Green("Hosts"))
		fmt.Printf("\n%s %s Finished\n", util.MarkerCyan, util.GetFormattedTime())
	},
}

HostDiscoveryCmd é o comando para executar a descoberta de hosts.

View Source
var PortScanCmd = &cobra.Command{
	Use:   "portscan",
	Short: "Performs a port scan on specified targets",
	Run: func(cmd *cobra.Command, args []string) {

		targets, fileMode := util.ParseTargetInput(psTarget)
		if len(targets) == 0 {
			log.Fatal().Msg(util.ErrInvalidTarget)
		}

		options := []string{}
		if psCustomOptions != "" {
			options = strings.Fields(psCustomOptions)
			for i, opt := range options {
				options[i] = strings.TrimSpace(opt)
			}
		}

		params := portscan.PortScanParams{
			Targets:    targets,
			OutputFile: psOutputFile,
			Mode:       psMode,
			Options:    options,
			PortList:   psPortList,
			Category:   psCategory,
			AllPorts:   psAllPorts,
			SimpleScan: psSimpleScan,
			FileMode:   fileMode,
		}

		strategy := portscan.NewNmapPortScanner()

		fmt.Printf("\n%s Port Scan", util.MarkerCyan)
		fmt.Printf("\n%s %s Starting\n", util.MarkerCyan, util.GetFormattedTime())

		orchestrator := portscan.NewPortScanOrchestrator(strategy, params)

		portscan.ShowConfiguration(params)

		ports, err := orchestrator.Run()
		if err != nil {
			log.Fatal().Msgf("%s %v", util.FatalErrPS, err)
		}

		fmt.Printf("%s Ports discovered 01: %s\n", util.MarkerGreen, util.Green(strconv.Itoa(len(ports))))
		fmt.Printf("\n%s %s Finished\n", util.MarkerCyan, util.GetFormattedTime())
	},
}

PortScanCmd é o comando para executar a varredura de portas.

Functions

func Execute

func Execute()

Execute executes the root command.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL