scanner

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverActiveHosts

func DiscoverActiveHosts(hosts []string, timeout time.Duration, numWorkers int) []string

DiscoverActiveHosts performs a quick host discovery on a CIDR range It attempts to connect to common ports (443, 80, 22, 445, 3306) to determine if hosts are active

func DiscoverActiveHostsWithOptions

func DiscoverActiveHostsWithOptions(hosts []string, opts DiscoveryOptions) []string

DiscoverActiveHostsWithOptions performs host discovery using configurable probe ports and concurrency.

func ExpandCIDR

func ExpandCIDR(cidr string) ([]string, error)

ExpandCIDR expands a CIDR notation to a list of IPs

func FormatCIDRInfo

func FormatCIDRInfo(target string) (string, int, error)

FormatCIDRInfo returns a human-readable description of what will be scanned

func GetTop1000Ports

func GetTop1000Ports() []int

GetTop1000Ports returns the top 1000 most commonly used ports

func IsCIDR

func IsCIDR(target string) bool

IsCIDR checks if a target is a CIDR range or single IP

func ParseTargets

func ParseTargets(target string) ([]string, error)

ParseTargets parses target(s) which can be single IP, multiple IPs, or CIDR notation Format: "192.168.1.1" or "192.168.1.0/24" or "192.168.1.1,192.168.1.5"

Types

type DiscoveryOptions

type DiscoveryOptions struct {
	Ports      []int
	Timeout    time.Duration
	NumWorkers int
}

DiscoveryOptions controls CIDR host discovery behavior.

type PortManager

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

PortManager handles port parsing and service mapping

func NewPortManager

func NewPortManager() *PortManager

NewPortManager creates a new PortManager instance

func (*PortManager) GetPortsToScan

func (pm *PortManager) GetPortsToScan(portsStr string) ([]int, error)

GetPortsToScan returns the list of ports to scan based on the specification

func (*PortManager) GetServiceName

func (pm *PortManager) GetServiceName(port int, bannerService string) string

GetServiceName returns the service name for a given port

func (*PortManager) ParsePorts

func (pm *PortManager) ParsePorts(portsStr string) ([]int, error)

ParsePorts parses a port specification string

type ScanConfig

type ScanConfig struct {
	NumWorkers      int
	Rate            int
	Timeout         time.Duration
	Retries         int
	AdaptiveTimeout bool
	BackoffBase     time.Duration
	MaxTimeout      time.Duration
	RandomAgent     bool
	RandomIP        bool
	TargetCIDR      string
}

ScanConfig contains runtime tuning controls for robust scans.

type ScanResult

type ScanResult struct {
	Port          int           `json:"port"`
	IsOpen        bool          `json:"open"`
	ServiceName   string        `json:"service,omitempty"`
	Version       string        `json:"version,omitempty"`
	Latency       time.Duration `json:"-"`
	LatencyMs     int64         `json:"latency_ms,omitempty"`
	Confidence    string        `json:"confidence,omitempty"`
	Evidence      string        `json:"evidence,omitempty"`
	DetectionPath string        `json:"detection_path,omitempty"`
}

ScanResult holds the result of a single port scan

type Scanner

type Scanner struct {
	Host               string
	NumWorkers         int
	Rate               int
	Timeout            time.Duration
	Retries            int
	AdaptiveTimeout    bool
	BackoffBase        time.Duration
	BackoffMax         time.Duration
	MinAdaptiveTimeout time.Duration
	MaxAdaptiveTimeout time.Duration
	PortManager        *PortManager
	GhostMode          bool
	RandomAgent        bool
	RandomIP           bool
	// contains filtered or unexported fields
}

Scanner handles the port scanning logic

func NewScanner

func NewScanner(host string, ghostMode bool) *Scanner

NewScanner creates a new Scanner instance

func (*Scanner) Configure

func (s *Scanner) Configure(cfg ScanConfig)

Configure overrides scanner defaults with validated values.

func (*Scanner) Scan

func (s *Scanner) Scan(ports []int, detectServices bool) []ScanResult

Scan performs the port scanning operation

Jump to

Keyboard shortcuts

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