scan

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolICMP     = 1
	ProtocolIPv6ICMP = 58
)

Some constants

View Source
const (
	DeadlineSec = 10
)

Variables

This section is empty.

Functions

func CleanupHandlersUnix

func CleanupHandlersUnix(s *Scanner)

CleanupHandlers for all interfaces

func DiscoveredHost

func DiscoveredHost(host string) string

func GetInterfaceFromIP

func GetInterfaceFromIP(ip net.IP) (*net.Interface, error)

GetInterfaceFromIP gets the name of the network interface from local ip address

func NewScannerUnix

func NewScannerUnix(scanner *Scanner) error

NewScannerUnix creates a new instance specific for unix OS

func ServiceScan added in v0.1.1

func ServiceScan(ip string, port int) (string, string, string)

func SetupHandlerUnix

func SetupHandlerUnix(s *Scanner, interfaceName, bpfFilter string, protocols ...protocol.Protocol) error

SetupHandlerUnix on unix OS

func TransportReadWorkerPCAPUnix

func TransportReadWorkerPCAPUnix(s *Scanner)

TransportReadWorkerPCAPUnix for TCP and UDP

Types

type Handlers

type Handlers struct {
	TransportActive   []*pcap.Handle
	TransportInactive []*pcap.InactiveHandle
	EthernetActive    []*pcap.Handle
	EthernetInactive  []*pcap.InactiveHandle
}

Handlers contains the list of pcap handlers

type OptionsScanner

type OptionsScanner struct {
	Timeout     time.Duration
	Retries     int
	Rate        int
	Debug       bool
	ExcludedIps []string
	Proxy       string
	ProxyAuth   string
	Stream      bool
}

Options of the scan

type Phase

type Phase struct {
	sync.RWMutex
	State
}

func (*Phase) Is

func (phase *Phase) Is(state State) bool

func (*Phase) Set

func (phase *Phase) Set(state State)

type Ping

type Ping struct {
	Type    PingResultType
	Latency time.Duration
	Error   error
	Host    string
}

Ping contains the results for ping on a single host

type PingResult

type PingResult struct {
	Hosts []Ping
}

PingResult contains the results for the Ping request

func PingHosts

func PingHosts(addresses []string) (*PingResult, error)

PingHosts pings the addresses given and returns the latencies of each host If the address returns an error, that address is marked as unusable.

func (*PingResult) GetFastestHost

func (p *PingResult) GetFastestHost() (Ping, error)

GetFastestHost gets the fastest host from the ping responses

type PingResultType

type PingResultType int

PingResultType contains the type of result for ping request on an address

const (
	HostInactive PingResultType = iota
	HostActive
)

Type of ping responses

type PkgFlag

type PkgFlag int

PkgFlag represent the TCP packet flag

const (
	Syn PkgFlag = iota
	Ack
)

type PkgResult

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

PkgResult contains the results of sending TCP packages

type PkgSend

type PkgSend struct {
	SourceIP string
	// contains filtered or unexported fields
}

PkgSend is a TCP package

type Scanner

type Scanner struct {
	Router    routing.Router
	SourceIP4 net.IP
	SourceIP6 net.IP

	SourcePort int

	Ports    []*port.Port
	IPRanger *ipranger.IPRanger

	Phase            Phase
	ScanResults      *result.Result
	NetworkInterface *net.Interface

	PortCount int32
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(options *OptionsScanner) (*Scanner, error)

NewScanner creates a new full port scanner that scans all ports using SYN packets.

func (*Scanner) ACKPort

func (s *Scanner) ACKPort(dstIP string, port int, timeout time.Duration) (bool, error)

ACKPort sends an ACK packet to a port

func (*Scanner) CleanupHandlers

func (s *Scanner) CleanupHandlers()

CleanupHandlers for all interfaces

func (*Scanner) Close

func (s *Scanner) Close()

Close the scanner and terminate all workers

func (*Scanner) ConnectPort

func (s *Scanner) ConnectPort(host string, p *port.Port, timeout time.Duration) (bool, error)

func (*Scanner) EnqueueTCP

func (s *Scanner) EnqueueTCP(ip string, pkgtype PkgFlag, ports ...*port.Port)

EnqueueTCP outgoing TCP packets

func (*Scanner) NmapServiceProbesScan

func (s *Scanner) NmapServiceProbesScan(host string, ports []*port.Port) []*port.Port

func (*Scanner) PavoConfigName added in v0.1.1

func (s *Scanner) PavoConfigName() string

func (*Scanner) PavoPortScan added in v0.1.1

func (s *Scanner) PavoPortScan(ip string, size int) (pavo.Results, error)

func (*Scanner) ScanSyn

func (s *Scanner) ScanSyn(ip string)

ScanSyn a target ip

func (*Scanner) SendAsyncPkg

func (s *Scanner) SendAsyncPkg(ip string, p *port.Port, pkgFlag PkgFlag)

SendAsyncPkg sends a single packet to a port

func (*Scanner) SetupHandler

func (s *Scanner) SetupHandler(interfaceName string) error

SetupHandler to listen on the specified interface

func (*Scanner) SetupHandlers

func (s *Scanner) SetupHandlers() error

SetupHandlers to listen on all interfaces

func (*Scanner) StartWorkers

func (s *Scanner) StartWorkers()

StartWorkers of the scanner

func (*Scanner) TCPReadWorker4

func (s *Scanner) TCPReadWorker4()

TCPReadWorker4 reads and parse incoming TCP packets

func (*Scanner) TCPReadWorker6

func (s *Scanner) TCPReadWorker6()

TCPReadWorker4 reads and parse incoming TCP packets

func (*Scanner) TCPReadWorkerPCAP

func (s *Scanner) TCPReadWorkerPCAP()

TCPReadWorkerPCAP reads and parse incoming TCP packets with pcap

func (*Scanner) TCPResultWorker

func (s *Scanner) TCPResultWorker()

TCPResultWorker handles probes and scan results

func (*Scanner) TransportWriteWorker

func (s *Scanner) TransportWriteWorker()

TCPWriteWorker that sends out TCP|UDP packets

type State

type State int

State determines the internal scan state

const (
	Init State = iota
	Scan
	Done
	Guard
)

type TCPSequencer

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

TCPSequencer generates linear TCP sequence numbers that wrap around after reaching their maximum value.

According to specs, this is the correct way to approach TCP sequence number since linearity will be guaranteed by the wrapping around to initial 0.

func NewTCPSequencer

func NewTCPSequencer() *TCPSequencer

NewTCPSequencer creates a new linear tcp sequenc enumber generator

func (*TCPSequencer) Next

func (t *TCPSequencer) Next() uint32

Next returns the next number in the sequence of tcp sequence numbers

Jump to

Keyboard shortcuts

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