Documentation
¶
Overview ¶
Package internal provides core scanning functionality and shared types for scanorama. It contains scan execution logic, result processing, XML handling, and common data structures used throughout the application.
Index ¶
- func PrintResults(result *ScanResult)
- func SaveResults(result *ScanResult, filePath string) error
- type Host
- type HostStats
- type HostXML
- type Port
- type PortXML
- type ScanConfig
- type ScanError
- type ScanResult
- func LoadResults(filePath string) (*ScanResult, error)
- func NewScanResult() *ScanResult
- func RunScan(config *ScanConfig) (*ScanResult, error)
- func RunScanWithContext(ctx context.Context, config *ScanConfig, database *db.DB) (*ScanResult, error)
- func RunScanWithDB(config *ScanConfig, database *db.DB) (*ScanResult, error)
- type ScanXML
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintResults ¶
func PrintResults(result *ScanResult)
PrintResults displays scan results in a human-readable format on stdout. The output includes host status, open ports, and detected services.
func SaveResults ¶
func SaveResults(result *ScanResult, filePath string) error
SaveResults writes scan results to an XML file at the specified path. The output is formatted with proper indentation for readability.
Types ¶
type Host ¶
type Host struct {
// Address is the IP address or hostname of the scanned host
Address string
// Status indicates whether the host is "up" or "down"
Status string
// Ports contains information about all scanned ports
Ports []Port
}
Host represents a scanned host and its findings.
type HostStats ¶
type HostStats struct {
// Up is the number of hosts that were up
Up int
// Down is the number of hosts that were down
Down int
// Total is the total number of hosts scanned
Total int
}
HostStats contains summary statistics about a network scan.
type HostXML ¶
type HostXML struct {
Address string `xml:"Address"`
Status string `xml:"Status"`
Ports []PortXML `xml:"Ports,omitempty"`
}
HostXML represents a scanned host for XML serialization. It contains the host's address, status, and discovered ports.
type Port ¶
type Port struct {
// Number is the port number (1-65535)
Number uint16
// Protocol is the transport protocol ("tcp" or "udp")
Protocol string
// State indicates whether the port is "open", "closed", or "filtered"
State string
// Service is the name of the detected service, if any
Service string
// Version is the version of the detected service, if available
Version string
// ServiceInfo contains additional service details, if available
ServiceInfo string
}
Port represents the scan results for a single port.
type PortXML ¶
type PortXML struct {
Number uint16 `xml:"Number"`
Protocol string `xml:"Protocol"`
State string `xml:"State"`
Service string `xml:"Service"`
Version string `xml:"Version,omitempty"`
ServiceInfo string `xml:"ServiceInfo,omitempty"`
}
PortXML represents a scanned port for XML serialization. It includes the port number, protocol, state, and service information.
type ScanConfig ¶
type ScanConfig struct {
// Targets is a list of targets to scan (IPs, hostnames, CIDR ranges)
Targets []string
// Ports specifies which ports to scan (e.g., "80,443" or "1-1000")
Ports string
// ScanType determines the type of scan: "connect", "syn", or "version"
ScanType string
// TimeoutSec specifies scan timeout in seconds (0 = default timeout)
TimeoutSec int
// Concurrency specifies the number of concurrent scans (0 = auto)
Concurrency int
// RetryCount specifies the number of retry attempts for failed scans
RetryCount int
// RetryDelay specifies the delay between retries
RetryDelay time.Duration
}
ScanConfig represents the configuration for a network scan.
func (*ScanConfig) Validate ¶
func (c *ScanConfig) Validate() error
Validate checks if the scan configuration is valid.
type ScanError ¶
type ScanError struct {
Op string // Operation that failed
Err error // Original error
Host string // Host where the error occurred, if applicable
Port uint16 // Port where the error occurred, if applicable
}
ScanError represents error types for scan operations.
type ScanResult ¶
type ScanResult struct {
// Hosts contains all scanned hosts and their findings
Hosts []Host
// Stats contains summary statistics about the scan
Stats HostStats
// StartTime is when the scan started
StartTime time.Time
// EndTime is when the scan completed
EndTime time.Time
// Duration is how long the scan took
Duration time.Duration
// Error is any error that occurred during the scan
Error error
}
ScanResult contains the complete results of a network scan.
func LoadResults ¶
func LoadResults(filePath string) (*ScanResult, error)
LoadResults reads and parses scan results from an XML file. It returns the parsed results or an error if the file cannot be read or parsed.
func NewScanResult ¶
func NewScanResult() *ScanResult
NewScanResult creates a new scan result with the current time as start time.
func RunScan ¶
func RunScan(config *ScanConfig) (*ScanResult, error)
RunScan is a convenience wrapper around RunScanWithContext that uses a background context.
func RunScanWithContext ¶
func RunScanWithContext(ctx context.Context, config *ScanConfig, database *db.DB) (*ScanResult, error)
RunScanWithContext performs a network scan based on the provided configuration and context. It uses nmap to scan the specified targets and ports, returning detailed results about discovered hosts and services. If database is provided, results are stored.
func RunScanWithDB ¶
func RunScanWithDB(config *ScanConfig, database *db.DB) (*ScanResult, error)
RunScanWithDB is a convenience wrapper that includes database storage.
func (*ScanResult) Complete ¶
func (r *ScanResult) Complete()
Complete marks the scan as complete and calculates duration.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api provides HTTP REST API functionality for the Scanorama network scanner.
|
Package api provides HTTP REST API functionality for the Scanorama network scanner. |
|
handlers
Package handlers provides HTTP request handlers for the Scanorama API.
|
Package handlers provides HTTP request handlers for the Scanorama API. |
|
middleware
Package middleware provides HTTP middleware functions for the Scanorama API server.
|
Package middleware provides HTTP middleware functions for the Scanorama API server. |
|
Package config provides configuration management for scanorama.
|
Package config provides configuration management for scanorama. |
|
Package daemon provides the background service functionality for scanorama.
|
Package daemon provides the background service functionality for scanorama. |
|
Package db provides database connectivity and data models for scanorama.
|
Package db provides database connectivity and data models for scanorama. |
|
Package discovery provides network discovery functionality using nmap.
|
Package discovery provides network discovery functionality using nmap. |
|
Package errors provides structured error handling for scanorama operations.
|
Package errors provides structured error handling for scanorama operations. |
|
Package logging provides structured logging functionality using Go's slog package.
|
Package logging provides structured logging functionality using Go's slog package. |
|
Package metrics provides interfaces for metrics collection and monitoring.
|
Package metrics provides interfaces for metrics collection and monitoring. |
|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
|
Package profiles provides scanning profile management for scanorama.
|
Package profiles provides scanning profile management for scanorama. |
|
Package scheduler provides job scheduling and execution functionality for scanorama.
|
Package scheduler provides job scheduling and execution functionality for scanorama. |
|
Package services provides business logic services for Scanorama.
|
Package services provides business logic services for Scanorama. |
|
Package workers provides a worker pool implementation for concurrent operations in scanorama.
|
Package workers provides a worker pool implementation for concurrent operations in scanorama. |