scanner

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandMaker

type CommandMaker interface {
	MakeCommand(ctx context.Context, cmd string, args ...string) CommandRunner
}

CommandMaker is a stand-in for creating and instance of exec.Cmd directly.

type CommandRunner

type CommandRunner interface {
	RunCommand(stdout io.Writer, stderr io.Writer) error
}

CommandRunner is a stand-in for calling cmd.Run() while also capturing input.

type Component

type Component struct {
	LogFn domain.LogFn
}

Component loads a Scanner.

func NewComponent

func NewComponent(logFN domain.LogFn) *Component

NewComponent populates the defaults.

func (*Component) New

func (c *Component) New(ctx context.Context, conf *Config) (*NMAP, error)

New constructs a scanner.

func (*Component) Settings

func (*Component) Settings() *Config

Settings generates the default settings.

type Config

type Config struct {
	BinPath    string   `description:"Nmap binary path to execute."`
	BinArgs    []string `description:"Nmap flags to pass to the binary. Note that -sV and -oX are always passed."`
	Scripts    []string `description:"Nmap scripts to execute. Paths must be relative to the nmap script root."`
	ScriptArgs []string `description:"Any script arguments to inject. Form of argname='argvalue'"`
}

Config contains options for the Scanner.

func (*Config) Name

func (*Config) Name() string

Name of the configuration root.

type ExecCmd

type ExecCmd struct {
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

ExecCmd implements CommandRunner using exec.Cmd.

func (*ExecCmd) RunCommand

func (c *ExecCmd) RunCommand(stdout io.Writer, stderr io.Writer) error

RunCommand executes the bundled command and returns the results

type ExecMaker

type ExecMaker struct{}

ExecMaker implements the CommandMaker using exec.Cmd.

func (*ExecMaker) MakeCommand

func (*ExecMaker) MakeCommand(ctx context.Context, cmd string, args ...string) CommandRunner

MakeCommand generates a CommandRunner implemented by ExecCmd.

type LoggingCmd

type LoggingCmd struct {
	LogFn         domain.LogFn
	Ctx           context.Context
	CommandRunner CommandRunner
	Cmd           string
	Args          []string
}

LoggingCmd emits debug logs when a command is issued.

func (*LoggingCmd) RunCommand

func (c *LoggingCmd) RunCommand(stdout io.Writer, stderr io.Writer) error

RunCommand captures the shell output.

type LoggingMaker

type LoggingMaker struct {
	LogFn        domain.LogFn
	CommandMaker CommandMaker
}

LoggingMaker wraps a CommandMaker in order to provide debug logging of shell commands.

func (*LoggingMaker) MakeCommand

func (m *LoggingMaker) MakeCommand(ctx context.Context, cmd string, args ...string) CommandRunner

MakeCommand wraps the output of the nested maker with logging.

type NMAP

type NMAP struct {
	BinPath        string
	BinArgs        []string
	Scripts        []string
	ScriptArgs     []string
	CommandStrings []string
	CommandMaker   CommandMaker
}

NMAP implements the scanner interface by making a subprocess call to nmap.

func NewNMAP

func NewNMAP(binPath string, binArgs []string, scripts []string, scriptArgs []string) *NMAP

NewNMAP generates a Scanner implementation tha leverages NMAP internally.

func (*NMAP) Scan

func (s *NMAP) Scan(ctx context.Context, host string) ([]domain.Finding, error)

Scan a host using nmap.

func (*NMAP) ScanWithScripts

func (s *NMAP) ScanWithScripts(ctx context.Context, scripts []string, scriptArgs []string, host string) ([]domain.Finding, error)

ScanWithScripts overrides the default script and script arguments.

func (*NMAP) WithScriptArgs

func (s *NMAP) WithScriptArgs(args []string) *NMAP

WithScriptArgs overrides the active scripts arguments for a scan.

func (*NMAP) WithScripts

func (s *NMAP) WithScripts(scripts []string) *NMAP

WithScripts overrides the active scripts for a scan.

Jump to

Keyboard shortcuts

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