scanner

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArpScanResult

type ArpScanResult struct {
	IP       net.IP
	MAC      net.HardwareAddr
	Hostname string
	Vendor   string
}

ArpScanResult represents a single network device result from arp scan

func (*ArpScanResult) Serializable

func (r *ArpScanResult) Serializable() interface{}

Serializable returns a serializable version of ArpScanResult

type ArpScanner

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

ArpScanner implements the Scanner interface for ARP scanning

func NewArpScanner

func NewArpScanner(
	targets []string,
	networkInfo network.Network,
	options ...Option,
) *ArpScanner

NewArpScanner returns a new instance of ArpScanner

func (*ArpScanner) IncludeHostNames added in v1.15.0

func (s *ArpScanner) IncludeHostNames(v bool)

IncludeHostNames sets whether reverse dns look up is performed to find hostname

func (*ArpScanner) IncludeVendorInfo

func (s *ArpScanner) IncludeVendorInfo(repo oui.VendorRepo)

IncludeVendorInfo sets whether or not to include vendor info in the scan

func (*ArpScanner) Results added in v1.12.0

func (s *ArpScanner) Results() chan *ScanResult

Results returns the results channel for notifying when a target arp reply is detected

func (*ArpScanner) Scan

func (s *ArpScanner) Scan() error

Scan implements the Scan method for ARP scanning

func (*ArpScanner) SetIdleTimeout

func (s *ArpScanner) SetIdleTimeout(duration time.Duration)

SetIdleTimeout sets the idle timeout for this scanner

func (*ArpScanner) SetPacketCapture added in v1.9.0

func (s *ArpScanner) SetPacketCapture(cap PacketCapture)

SetPacketCapture sets the data structure used for capture packets

func (*ArpScanner) SetRequestNotifications

func (s *ArpScanner) SetRequestNotifications(c chan *Request)

SetRequestNotifications sets the channel for notifying when ARP requests are sent

func (*ArpScanner) SetTiming added in v1.14.0

func (s *ArpScanner) SetTiming(d time.Duration)

SetTiming sets the timing duration for how long to wait in-between packet sends for ARP requests

func (*ArpScanner) Stop

func (s *ArpScanner) Stop()

Stop stops the scanner

type FullScanner

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

FullScanner implements Scanner interface to perform both ARP and SYN scanning

func NewFullScanner

func NewFullScanner(
	netInfo network.Network,
	targets,
	ports []string,
	listenPort uint16,
	options ...Option,
) *FullScanner

NewFullScanner returns a new instance of FullScanner

func (*FullScanner) IncludeHostNames added in v1.15.0

func (s *FullScanner) IncludeHostNames(v bool)

IncludeHostNames sets whether reverse dns look up is performed to find hostname

func (*FullScanner) IncludeVendorInfo

func (s *FullScanner) IncludeVendorInfo(repo oui.VendorRepo)

IncludeVendorInfo sets whether or not to include vendor info when scanning

func (*FullScanner) Results added in v1.12.0

func (s *FullScanner) Results() chan *ScanResult

Results returns the channel used for notifying of new scan results

func (*FullScanner) Scan

func (s *FullScanner) Scan() error

Scan implements ARP and SYN scanning

func (*FullScanner) SetIdleTimeout

func (s *FullScanner) SetIdleTimeout(d time.Duration)

SetIdleTimeout sets the idle timeout for ARP and SYN scanning

func (*FullScanner) SetPacketCapture added in v1.9.0

func (s *FullScanner) SetPacketCapture(cap PacketCapture)

SetPacketCapture sets the packet capture implementation for this scanner

func (*FullScanner) SetRequestNotifications

func (s *FullScanner) SetRequestNotifications(c chan *Request)

SetRequestNotifications sets the channel for notifying when SYN & ARP requests are sent

func (*FullScanner) SetTiming added in v1.14.0

func (s *FullScanner) SetTiming(d time.Duration)

SetTiming sets the timing duration for how long to wait in-between packet sends for both ARP & SYN requests

func (*FullScanner) Stop

func (s *FullScanner) Stop()

Stop stops the scanner

type Option added in v1.14.1

type Option = func(s Scanner)

Option represents an option that can be passed to any of the "New" scanner constructors

func WithHostnames added in v1.15.0

func WithHostnames(v bool) Option

WithHostnames sets whether or not to perform reverse dns lookup

func WithIdleTimeout

func WithIdleTimeout(duration time.Duration) Option

WithIdleTimeout sets the idle timeout for the scanner

func WithPacketCapture added in v1.9.0

func WithPacketCapture(cap PacketCapture) Option

WithPacketCapture sets the packet capture implementation for the scanner

func WithRequestNotifications

func WithRequestNotifications(c chan *Request) Option

WithRequestNotifications sets channel for request notifications

func WithTiming added in v1.14.0

func WithTiming(duration time.Duration) Option

WithTiming sets the timing duration for how long to wait in-between each packet send

func WithVendorInfo

func WithVendorInfo(repo oui.VendorRepo) Option

WithVendorInfo sets whether or not to include vendor info when scanning

type PacketCapture added in v1.9.0

type PacketCapture interface {
	OpenLive(device string, snaplen int32, promisc bool, timeout time.Duration) (handle PacketCaptureHandle, _ error)
	SerializeLayers(w gopacket.SerializeBuffer, opts gopacket.SerializeOptions, layers ...gopacket.SerializableLayer) error
}

PacketCapture interface for creating PacketCaptureHandles and serializing packet layers

type PacketCaptureHandle added in v1.9.0

type PacketCaptureHandle interface {
	Close()
	ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error)
	ZeroCopyReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error)
	WritePacketData(data []byte) (err error)
	SetBPFFilter(expr string) (err error)
}

PacketCaptureHandle interface for writing and reading packets to and from the wire

type Port

type Port struct {
	ID      uint16     `json:"id"`
	Service string     `json:"service"`
	Status  PortStatus `json:"status"`
}

Port data structure representing a server port

type PortStatus

type PortStatus string

PortStatus represents possible port statuses

const (
	// PortOpen status used when a port is marked open
	PortOpen PortStatus = "open"
	// PortClosed status used when a port is marked closed
	PortClosed PortStatus = "closed"
)

type Request

type Request struct {
	Type RequestType
	IP   string
	Port uint16
}

Request represents a notification for a request packet sent to target host

type RequestType

type RequestType string

RequestType represents a type of request packet sent to target

const (
	// ArpRequest represents an ARP request
	ArpRequest RequestType = "ARP"
	// SynRequest represents a SYN request
	SynRequest RequestType = "SYN"
)

type ResultType

type ResultType string

ResultType represents a type of result sent through the result channel in each scanner implementation

const (
	// ARPResult represents an ARP Result message
	ARPResult ResultType = "ARP"
	// ARPDone represents an ARP Done message
	ARPDone ResultType = "ARP_DONE"
	// SYNResult represents an SYN Result message
	SYNResult ResultType = "SYN"
	// SYNDone represents an SYN Done message
	SYNDone ResultType = "SYN_DONE"
)

type ScanResult

type ScanResult struct {
	Type    ResultType
	Payload any
}

ScanResult represents a scanning result sent through the results channel in each in scanner implementation

type Scanner

type Scanner interface {
	Scan() error
	Stop()
	Results() chan *ScanResult
	SetTiming(d time.Duration)
	SetRequestNotifications(c chan *Request)
	SetIdleTimeout(d time.Duration)
	IncludeVendorInfo(repo oui.VendorRepo)
	IncludeHostNames(v bool)
	SetPacketCapture(cap PacketCapture)
}

Scanner interface for scanning network devices

type Status

type Status string

Status represents possible server statues

const (
	// StatusUnknown unknown status for server
	StatusUnknown Status = "unknown"
	// StatusOnline status if server is online
	StatusOnline Status = "online"
	// StatusOffline status if server is offline
	StatusOffline Status = "offline"
)

type SynPacket added in v1.13.0

type SynPacket struct {
	IP4 *layers.IPv4
	TCP *layers.TCP
}

SynPacket represents a SYN packet response from one of the targeted hosts

type SynScanResult

type SynScanResult struct {
	MAC    net.HardwareAddr
	IP     net.IP
	Status Status
	Port   Port
}

SynScanResult represents a single network device result from syn scan

type SynScanner

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

SynScanner implements the Scanner interface for SYN scanning

func NewSynScanner

func NewSynScanner(
	targets []*ArpScanResult,
	networkInfo network.Network,
	ports []string,
	listenPort uint16,
	options ...Option,
) *SynScanner

NewSynScanner returns a new instance of SYNScanner

func (*SynScanner) IncludeHostNames added in v1.15.0

func (s *SynScanner) IncludeHostNames(v bool)

IncludeHostNames sets whether reverse dns look up is performed to find hostname

func (*SynScanner) IncludeVendorInfo

func (s *SynScanner) IncludeVendorInfo(_ oui.VendorRepo)

IncludeVendorInfo N/A for SYN scanner but here to satisfy Scanner interface

func (*SynScanner) Results added in v1.12.0

func (s *SynScanner) Results() chan *ScanResult

Results returns the channel for notifying when SYN responses are received from targeted hosts

func (*SynScanner) Scan

func (s *SynScanner) Scan() error

Scan implements SYN scanning

func (*SynScanner) SetIdleTimeout

func (s *SynScanner) SetIdleTimeout(duration time.Duration)

SetIdleTimeout sets the idle timeout for this scanner

func (*SynScanner) SetPacketCapture added in v1.9.0

func (s *SynScanner) SetPacketCapture(cap PacketCapture)

SetPacketCapture sets the packet capture implementation for this scanner

func (*SynScanner) SetRequestNotifications

func (s *SynScanner) SetRequestNotifications(c chan *Request)

SetRequestNotifications sets the channel for notifying when SYN requests are sent

func (*SynScanner) SetTargets added in v1.12.0

func (s *SynScanner) SetTargets(targets []*ArpScanResult)

SetTargets sets the targets for SYN scanning

func (*SynScanner) SetTiming added in v1.14.0

func (s *SynScanner) SetTiming(d time.Duration)

SetTiming sets the timing duration for how long to wait in-between packet sends for SYN requests

func (*SynScanner) Stop

func (s *SynScanner) Stop()

Stop stops the scanner

Jump to

Keyboard shortcuts

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