networkdetect

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const FlightSimRevision = "3709d1c6905d9527885c62f66f49a955c7b0d191"
View Source
const StatsFilename = "NetworkDetection.json"

Variables

This section is empty.

Functions

func BeaconStats

func BeaconStats(times []int64) (mean, jitter float64)

BeaconStats summarizes the intervals between consecutive connection starts. Jitter is the coefficient of variation (standard deviation / mean).

func SyntheticOnlyCase

func SyntheticOnlyCase(name string) bool

SyntheticOnlyCase reports qualification cases without a captured FlightSim execution: the benign controls and periodic beacons, which FlightSim at the pinned revision does not generate.

Types

type ApplicationEngine

type ApplicationEngine struct {
	Alerts, Overflow uint64
	Late             uint64
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(c Config) *ApplicationEngine

func (*ApplicationEngine) AggregationStats added in v0.16.0

func (e *ApplicationEngine) AggregationStats() (matches, capacity uint64)

func (*ApplicationEngine) Checkpoint added in v0.16.0

func (e *ApplicationEngine) Checkpoint() []*types.Alert

Checkpoint emits partial aggregates without advancing capture time or resetting scan/beacon history. Delayed older records remain explicit Late.

func (*ApplicationEngine) Flush added in v0.16.0

func (e *ApplicationEngine) Flush() []*types.Alert

func (*ApplicationEngine) Observe

func (e *ApplicationEngine) Observe(o ApplicationObservation) (alerts []*types.Alert)

type ApplicationObservation

type ApplicationObservation struct {
	At                                             int64
	Scope                                          Scope
	Kind, SrcIP, DstIP                             string
	SrcPort, DstPort                               uint16
	Method, Path, Host, CommunityID, Qualification string
	Status                                         int
	Executable                                     bool
}

func Observation

func Observation(m proto.Message) (ApplicationObservation, bool)

type Config

type Config struct {
	WindowNS         int64       `json:"windowNS"`
	DedupNS          int64       `json:"dedupNS"` // Legacy name: aggregation window; 0 emits every match immediately.
	MaxKeys          int         `json:"maxKeys"`
	MaxFlows         int         `json:"maxFlows"`
	DNSNames         int         `json:"dnsNames"`
	ScanTargets      int         `json:"scanTargets"`
	SMTPHosts        int         `json:"smtpHosts"`
	ICMPEchoes       int         `json:"icmpEchoes"`
	SSHBytes         uint64      `json:"sshBytes"`
	ApprovedSources  []string    `json:"approvedSources"`
	Indicators       []Indicator `json:"indicators"`
	SMTPRelays       []string    `json:"smtpRelays"`       // Source IPs/CIDRs; SMTP-only exemption requires at least one endpoint in InternalNetworks.
	InternalNetworks []string    `json:"internalNetworks"` // CIDRs defining network roles, never inferred from private addressing.

	// Periodic TCP connection starts from one source to one service. Samples
	// is the number of connection starts examined (0 disables), Jitter the
	// largest accepted coefficient of variation of their intervals.
	BeaconSamples       int     `json:"beaconSamples"`
	BeaconJitter        float64 `json:"beaconJitter"`
	BeaconMinIntervalNS int64   `json:"beaconMinIntervalNS"`
	BeaconWindowNS      int64   `json:"beaconWindowNS"`
}

func DefaultConfig

func DefaultConfig() Config

func LoadConfig

func LoadConfig(path string) (Config, error)

func (Config) Validate

func (c Config) Validate() error

type Engine

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

func New

func New(c Config) (*Engine, error)

func (*Engine) Checkpoint added in v0.16.0

func (e *Engine) Checkpoint() []*types.Alert

Checkpoint emits pending live matches without moving the event watermark. Rows across checkpoints retain their AggregateKey and disjoint match counts.

func (*Engine) Flush added in v0.16.0

func (e *Engine) Flush() []*types.Alert

Flush finalizes pending matches at EOF/shutdown; repeated calls emit nothing.

func (*Engine) Observe

func (e *Engine) Observe(ev Event) (alerts []*types.Alert, err error)

func (*Engine) Stats

func (e *Engine) Stats() Stats

type Event

type Event struct {
	At      int64  `json:"at"`
	Scope   Scope  `json:"scope"`
	Kind    string `json:"kind"`
	SrcIP   string `json:"srcIP"`
	DstIP   string `json:"dstIP"`
	SrcPort uint16 `json:"srcPort,omitempty"`
	DstPort uint16 `json:"dstPort,omitempty"`
	Name    string `json:"name,omitempty"`
	QType   uint16 `json:"qType,omitempty"`
	Seq     uint32 `json:"seq,omitempty"`
	Payload []byte `json:"payload,omitempty"`
}

Event is capture-derived; fixture scenario labels are never detector inputs.

func PacketEvents

func PacketEvents(packet gopacket.Packet, scope Scope) []Event

type Evidence

type Evidence struct {
	Schema         int        `json:"schema"`
	Detector       string     `json:"detector"`
	Classification string     `json:"classification"`
	Scope          Scope      `json:"scope"`
	FirstSeen      int64      `json:"firstSeen"`
	LastSeen       int64      `json:"lastSeen"`
	Observed       uint64     `json:"observed"`
	Threshold      uint64     `json:"threshold"`
	WindowNS       int64      `json:"windowNS"`
	Samples        []string   `json:"samples"`
	Limitations    []string   `json:"limitations"`
	Indicator      *Indicator `json:"indicator,omitempty"`
}

type Indicator

type Indicator struct {
	Value      string `json:"value"`
	Kind       string `json:"kind"`
	Category   string `json:"category"`
	Source     string `json:"source"`
	Version    string `json:"version"`
	ValidFrom  int64  `json:"validFrom"`
	ValidUntil int64  `json:"validUntil"`
}

type Scope

type Scope struct {
	Sensor    string   `json:"sensor"`
	Interface string   `json:"interface"`
	VLANs     []uint16 `json:"vlans,omitempty"`
}

func PacketScope

func PacketScope(packet gopacket.Packet, scope Scope) Scope

type Stats

type Stats struct {
	Matches                uint64 `json:"matches"`
	PendingAggregates      int    `json:"pendingAggregates"`
	CapacityFlushes        uint64 `json:"capacityFlushes"`
	FTPDataExclusions      uint64 `json:"ftpDataExclusions"`
	SMTPRelayExclusions    uint64 `json:"smtpRelayExclusions"`
	AggregationMode        string `json:"aggregationMode,omitempty"`
	ApplicationMode        string `json:"applicationMode,omitempty"`
	ApplicationAlerts      uint64 `json:"applicationAlerts,omitempty"`
	ApplicationQueuedBytes int64  `json:"applicationQueuedBytes,omitempty"`
	ApplicationPeakBytes   int64  `json:"applicationPeakBytes,omitempty"`
	ApplicationQueueLimit  int64  `json:"applicationQueueLimit,omitempty"`
	ApplicationQueueDrops  uint64 `json:"applicationQueueDrops,omitempty"`
	ApplicationLate        uint64 `json:"applicationLate,omitempty"`
	Schema                 int    `json:"schema"`
	Events                 uint64 `json:"events"`
	Alerts                 uint64 `json:"alerts"`
	Overflow               uint64 `json:"overflow"`
	Late                   uint64 `json:"late"`
	StreamGaps             uint64 `json:"streamGaps"`
	Keys                   int    `json:"keys"`
	Flows                  int    `json:"flows"`
	Indicators             int    `json:"indicators"`
	Error                  string `json:"error,omitempty"`
}

func ReadStats

func ReadStats(path string) (Stats, error)

Jump to

Keyboard shortcuts

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