scan

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeadlineSec  = 10
	ProtocolICMP = 1
)

Some constants

Variables

This section is empty.

Functions

func CleanupHandlersUnix

func CleanupHandlersUnix(s *Scanner)

CleanupHandlersUnix CleanupHandlers for all interfaces

func GetInterfaceFromIP

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

GetInterfaceFromIP 通过IP获取网卡名称、mac地址 GetInterfaceFromIP gets the name of the network interface from local ip address

func GetSourceIP

func GetSourceIP(dstip net.IP) (net.IP, error)

GetSourceIP gets the local ip based on our destination ip

func GetSrcParameters

func GetSrcParameters(destIP string) (srcIP net.IP, networkInterface *net.Interface, err error)

GetSrcParameters gets the network parameters from the destination ip

func NewScannerUnix

func NewScannerUnix(scanner *Scanner) error

func SetupHandlerUnix

func SetupHandlerUnix(s *Scanner, interfaceName string) error

func TCPReadWorkerPCAPUnix

func TCPReadWorkerPCAPUnix(s *Scanner)

Types

type Handlers

type Handlers struct {
	Active   []*pcap.Handle
	Inactive []*pcap.InactiveHandle
}

type Options

type Options struct {
	Timeout time.Duration
	Retries int
	Rate    int
	Debug   bool
	Proxy   string
	Stream  bool
}

Options of the scan

type PkgFlag

type PkgFlag int

PkgFlag represent the TCP packet flag

const (
	SYN PkgFlag = iota
	ACK
	ICMPECHOREQUEST
	ICMPTIMESTAMPREQUEST
)

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 Result

type Result struct {
	sync.RWMutex
	IPPorts map[string]map[int]struct{}
	IPS     map[string]struct{}
}

func NewResult

func NewResult() *Result

NewResult structure

func (*Result) AddPort

func (r *Result) AddPort(k string, v int)

AddPort to a specific ip

func (*Result) SetPorts

func (r *Result) SetPorts(k string, v map[int]struct{})

SetPorts for a specific ip

type Scanner

type Scanner struct {
	SourceIP         net.IP
	NetworkInterface *net.Interface

	Ports    []int
	IPRanger *ipranger.IPRanger

	State       State
	ScanResults *Result
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(options *Options) (*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, port int, timeout time.Duration) (bool, error)

ConnectPort a single host and port

func (*Scanner) ConnectVerify

func (s *Scanner) ConnectVerify(host string, ports map[int]struct{}) map[int]struct{}

ConnectVerify is used to verify if ports are accurate using a connect request

func (*Scanner) EnqueueICMP

func (s *Scanner) EnqueueICMP(ip string, pkgType PkgFlag)

EnqueueICMP outgoing ICMP packets

func (*Scanner) EnqueueToTCP

func (s *Scanner) EnqueueToTCP(ip string, port int, pkgType PkgFlag)

EnqueueToTCP 传出 TCP 数据包

func (*Scanner) ICMPReadWorker

func (s *Scanner) ICMPReadWorker()

ICMPReadWorker reads packets from the network layer

func (*Scanner) ICMPWriteWorker

func (s *Scanner) ICMPWriteWorker()

ICMPWriteWorker writes packet to the network layer

func (*Scanner) ScanSyn

func (s *Scanner) ScanSyn(ip string)

ScanSyn a target ip

func (*Scanner) SendAsyncPkg

func (s *Scanner) SendAsyncPkg(ip string, port int, pkgFlag PkgFlag)

SendAsyncPkg 将单个数据包发送到端口 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) StartListenScan

func (s *Scanner) StartListenScan()

StartListenScan of the scanner

func (*Scanner) TCPReadWorker

func (s *Scanner) TCPReadWorker()

TCPReadWorker reads and parse incoming TCP packets

func (*Scanner) TCPReadWorkerPCAP

func (s *Scanner) TCPReadWorkerPCAP()

TCPReadWorkerPCAP 使用 pcap 读取和解析传入的 TCP 数据包

func (*Scanner) TCPResultWorker

func (s *Scanner) TCPResultWorker()

TCPResultWorker 处理探测和扫描结果

func (*Scanner) TCPWriteWorker

func (s *Scanner) TCPWriteWorker()

TCPWriteWorker 发送 TCP 数据包的 TCPWriteWorker

func (*Scanner) TuneSource

func (s *Scanner) TuneSource(ip string) error

TuneSource 获取本机IP、网卡名称、mac地址 TuneSource automatically with ip and interface

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