scanner

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZGrab2AvailableScanners = []string{"ssh", "http"}

ZGrab2AvailableScanners holds a list of all ZGrab2 scanners that are ported and may be used

Functions

func PrepareScanFuncs

func PrepareScanFuncs(tcpscanner *TCPScanner, udpscanner *UDPScanner, targetMsg *nraySchema.MoreWorkReply, results chan<- *PortscanResult) <-chan func()

PrepareScanFuncs returns a channel where scan functions are sent over They are completely prepared and just have to be called

func RunNodeScannerLoop

func RunNodeScannerLoop(controller *ScanController, workBatchChan <-chan *nraySchema.MoreWorkReply, dataChan chan<- *nraySchema.NrayNodeMessage)

RunNodeScannerLoop orchestrates the actual scanning. It knows when to request work and how to perform communication between which scanning components pause is only used for controlling the scanning, so pause/continue can be supported. Reading/writing to it has to be synchronized The workbatch channel is used to send workbatches Data sent to dataChan will be picked by the nodes send/recv loop and transferred to the server, so it is used for sending requests for more work or reporting results TODO: Scan options

Types

type HTTPScanner

type HTTPScanner struct {
	// contains filtered or unexported fields
}

HTTPScanner type encapsulates configuration for scanning HTTP It implements the ProtocolScanner interface

func (*HTTPScanner) Configure

func (httpscanner *HTTPScanner) Configure(configuration *viper.Viper, nodeID string, nodeName string)

Configure is called with a configuration

func (*HTTPScanner) Register

func (httpscanner *HTTPScanner) Register(scanctrl *ScanController)

Register this scanner at the scan controller

type PauseIndicator

type PauseIndicator struct {
	// contains filtered or unexported fields
}

PauseIndicator is a type that can be used to indicate that a scanner should stop. Concurrency safe.

func (*PauseIndicator) GetValue

func (pi *PauseIndicator) GetValue() bool

GetValue returns the currently set value

func (*PauseIndicator) SetValue

func (pi *PauseIndicator) SetValue(value bool)

SetValue applies the new value

type PortscanResult

type PortscanResult struct {
	Target   string        `json:"Target"`
	Port     uint32        `json:"Port"`
	Open     bool          `json:"Open"`
	Scantype string        `json:"Scantype"`
	Timeout  time.Duration `json:"Timeout"`
}

PortscanResult is the struct that contains all information about the scan and the results

type ProtocolScanner

type ProtocolScanner interface {
	Configure(config *viper.Viper, nodeID string, nodeName string)
	Register(scanctrl *ScanController)
}

ProtocolScanner is the interface all scanners of higher level protocols must adhere to There is no explicit scan method because scanners register themselves for targets of interest and are called if something is found

func GetZGrab2Scanner

func GetZGrab2Scanner(ScannerName string) ProtocolScanner

GetZGrab2Scanner returns an instance of the requested scanner

type SSHScanner

type SSHScanner struct {
	// contains filtered or unexported fields
}

SSHScanner type encapsulates configuration for scanning SSH It implements the ProtocolScanner interface

func (*SSHScanner) Configure

func (sshscanner *SSHScanner) Configure(configuration *viper.Viper, nodeID string, nodeName string)

Configure is called with a configuration

func (*SSHScanner) Register

func (sshscanner *SSHScanner) Register(scanctrl *ScanController)

Register this scanner at the scan controller

type ScanController

type ScanController struct {

	// A map containing functions taking a proto, a host and a port that return
	// a function (closure) that can directly be called. The idea is that each scanner
	// may register itself e.g. for tcp/80 with a function taking those arguments.
	// If tcp/80 is discovered to be open, the function will be called and a closure
	// containing all relevant scanning information is returned. This closure can then
	// be queued in a channel and is picked up by the workers, simply calling the function
	// triggering the scan with the wrapped target information.
	Subscriptions map[string][]func(proto string, host string, port uint, results chan<- *nraySchema.Event) func()

	Pause *PauseIndicator
	// contains filtered or unexported fields
}

ScanController holds most information required to keep everything running

func CreateScanController

func CreateScanController(nodeID string, nodeName string, timeOffset time.Duration, scannerConfig *viper.Viper) *ScanController

CreateScanController initialises a new ScanController

func (*ScanController) Refresh

func (controller *ScanController) Refresh()

Refresh cleans the state for each workBatch. This is mainly required because termination of each run depends heavily on closing internal channels

func (*ScanController) Subscribe

func (controller *ScanController) Subscribe(key string, function func(string, string, uint, chan<- *nraySchema.Event) func())

Subscribe is called by protocol scanners to get notified in case interesting ports are open

type ScanTargets

type ScanTargets interface {
	// contains filtered or unexported methods
}

ScanTargets allows to abstract different types of target notations For regular scans the interface is sufficient, providing stream of targets whereas more specific implementations may expose data like networks or port ranges directly to be more efficient (e.g. when feeding to ZMap)

type StandardTargets

type StandardTargets struct {
	// contains filtered or unexported fields
}

StandardTargets is the default target implementation that allows for an arbitrary *single* host and multiple ports

type TCPPortScanner

type TCPPortScanner interface {
	Configure(config *viper.Viper)
	PrepareScanFuncs(targetMsg *nraySchema.MoreWorkReply, results chan<- *PortscanResult) <-chan func()
}

TCPPortScanner is the interface all TCP Port Scanners must adhere to

type TCPScanner

type TCPScanner struct {
	// contains filtered or unexported fields
}

TCPScanner represents the built-in TCP scanning functionality of nray If using other existing scanners or different scanning approaches are required, it should not be hard to replace this

func (*TCPScanner) Configure

func (tcpscan *TCPScanner) Configure(config *viper.Viper)

Configure loads a viper configuration and sets the appropriate values

type Target

type Target struct {
	// contains filtered or unexported fields
}

Target represents one specific target, meaning a service that is reachable knowing a proto (TCP/UDP), a destination (FQDN or IP) and a port

type UDPScanner

type UDPScanner struct {
	// contains filtered or unexported fields
}

UDPScanner contains the configuration for this scanner

func (*UDPScanner) Configure

func (udpscan *UDPScanner) Configure(config *viper.Viper)

Configure sets relevant configuration on this scanner

Jump to

Keyboard shortcuts

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