Documentation
¶
Index ¶
- Constants
- type Model
- func (m *Model) GetCorrelations(givenPort int) map[int]float64
- func (m *Model) Merge(other *Model)
- func (m *Model) Predict(openPorts []int, threshold float64) []PortPrediction
- func (m *Model) Prioritize(candidates []int, openPorts []int) []PortPrediction
- func (m *Model) Set(given, target int, probability float64)
- func (m *Model) SetBidirectional(portA, portB int, probAGivenB, probBGivenA float64)
- func (m *Model) Stats() (sourcePorts, totalEntries int)
- func (m *Model) Train(hostPorts map[string][]int)
- type PortPrediction
Constants ¶
const DefaultThreshold = 0.2
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model holds conditional probability data: P(TargetPort | GivenPort). The outer key is the known open port, the inner key is the predicted port.
func DefaultModel ¶
func DefaultModel() *Model
DefaultModel returns a model seeded with well-known port correlation patterns derived from common service co-occurrence on Internet hosts. Probabilities represent P(target | given), the likelihood that a host with "given" port open also has "target" port open.
func (*Model) GetCorrelations ¶
GetCorrelations returns all P(target | given) entries for a given port. The returned map is a copy safe for concurrent use.
func (*Model) Merge ¶
Merge adds correlations from another model, keeping the higher probability when both models have data for the same pair. Safe against cross-merge deadlocks: the source is snapshot-copied before acquiring the destination lock.
func (*Model) Predict ¶
func (m *Model) Predict(openPorts []int, threshold float64) []PortPrediction
Predict returns ports likely to be open given a set of known open ports. For each candidate port, the maximum conditional probability across all known ports is used (matching GPS's approach). Results are sorted by descending confidence and filtered by the threshold.
func (*Model) Prioritize ¶
func (m *Model) Prioritize(candidates []int, openPorts []int) []PortPrediction
Prioritize ranks candidate ports by their likelihood of being open, given a set of known open ports. For each candidate, the maximum conditional probability across all known open ports is used. All candidates are returned sorted by descending priority; candidates with no correlation data receive a score of 0.
func (*Model) SetBidirectional ¶
SetBidirectional stores the probability in both directions.
type PortPrediction ¶
PortPrediction is a predicted port with its confidence score.