Documentation
¶
Index ¶
- Variables
- func CalcCommunityIDSCTP(srcIP, dstIP string, srcPort, dstPort uint16) string
- func CalcCommunityIDTCP(srcIP, dstIP string, srcPort, dstPort uint16) string
- func CalcCommunityIDUDP(srcIP, dstIP string, srcPort, dstPort uint16) string
- func DecodeConversation(ident string, data core.DataFragments, client func(buf *bufio.Reader) error, ...)
- func DecodeConversationAt(ident string, data core.DataFragments, ...)
- func ResetStats()
- func SaveConversation(proto string, conversation core.DataFragments, ident string, ...) error
- func SaveDatagramConversation(source core.FragmentSource, ident string, first time.Time, ...) error
- func SaveNetworkConversation(protocol string, conversation NetworkDataFragments, ident string, ...) error
- func SaveSourceEvidence(out, protocol string, source core.FragmentSource, ident string, ...) (string, error)
- func SaveStreamEvidence(out, protocol string, conversation core.DataFragments, ident string, ...) (string, error)
- func SetLogger(l *zap.Logger)
- func SetReassemblyLogger(l *zap.Logger)
- func TransportQualification(observation string) string
- type NetworkDataFragment
- type NetworkDataFragments
- type ReadPosition
- type StreamEvidenceFile
- type StreamEvidenceManifest
- type StreamEvidenceSpan
- type TransportRun
Constants ¶
This section is empty.
Variables ¶
var DeviceEnricher func(ip string, hostnames, deviceTypes, roles []string, os string)
DeviceEnricher is a callback function to enrich a device profile by IP. Set by the collector during initialization to avoid circular imports.
var Stats struct { sync.Mutex IPdefrag int64 MissedBytes int64 Pkt int64 Sz int64 Totalsz int64 RejectFsm int64 RejectOpt int64 RejectChecksum int64 RejectIPv4Checksum int64 RejectConnFsm int64 Reassembled int64 OutOfOrderBytes int64 OutOfOrderPackets int64 BiggestChunkBytes int64 BiggestChunkPackets int64 OverlapBytes int64 OverlapPackets int64 SavedTCPConnections int64 SavedUDPConnections int64 SavedNetworkConnections int64 NumSoftware int64 NumServices int64 Requests int64 Responses int64 Count int64 DataBytes int64 NumConns int64 NumFlows int64 // HTTP NumUnmatchedResp int64 NumNilRequests int64 NumFoundRequests int64 NumRemovedRequests int64 NumUnansweredRequests int64 NumClientStreamNotFound int64 NumRequests int64 NumResponses int64 // keep this one after all 64bit types to fix alignment problems on ARM NumErrors uint }
Stats contains statistics about the stream reassembly.
Functions ¶
func CalcCommunityIDSCTP ¶
CalcCommunityIDSCTP calculates a Community ID v1 for an SCTP stream. Returns an empty string if the IP addresses cannot be parsed.
func CalcCommunityIDTCP ¶
CalcCommunityIDTCP calculates a Community ID v1 for a TCP stream. Returns an empty string if the IP addresses cannot be parsed.
func CalcCommunityIDUDP ¶
CalcCommunityIDUDP calculates a Community ID v1 for a UDP stream. Returns an empty string if the IP addresses cannot be parsed.
func DecodeConversation ¶
func DecodeConversation( ident string, data core.DataFragments, client func(buf *bufio.Reader) error, server func(buf *bufio.Reader) error, )
DecodeConversation is a Transport layer agnostic util to decode client / server data streams.
func DecodeConversationAt ¶
func DecodeConversationAt( ident string, data core.DataFragments, client func(buf *bufio.Reader, pos *ReadPosition) error, server func(buf *bufio.Reader, pos *ReadPosition) error, )
DecodeConversationAt is DecodeConversation with the read position exposed, so a reader can timestamp each message from the packet that carried it.
func ResetStats ¶
func ResetStats()
ResetStats clears all stream reassembly statistics This should be called when resetting state between processing different files
func SaveConversation ¶
func SaveConversation(proto string, conversation core.DataFragments, ident string, firstPacket time.Time, transport gopacket.Flow, communityID string) error
SaveConversation will save TCP / UDP conversations to disk this also invokes the harvesters on the conversation banner The communityID parameter is the Corelight Community ID v1 for the connection, calculated once at the stream level and passed through to harvesters.
func SaveDatagramConversation ¶ added in v0.16.8
func SaveNetworkConversation ¶
func SaveNetworkConversation(protocol string, conversation NetworkDataFragments, ident string, firstPacket time.Time) error
SaveNetworkConversation will save network-layer conversations (ICMP, IGMP, GRE, etc.) to disk Protocol should be the network layer protocol name (e.g., "ICMPv4", "ICMPv6", "IGMP", "GRE")
func SaveSourceEvidence ¶ added in v0.16.8
func SaveStreamEvidence ¶
func SaveStreamEvidence(out, protocol string, conversation core.DataFragments, ident string, first time.Time, communityID string) (string, error)
SaveStreamEvidence preserves payload bytes separately from presentation markup. Each call has its own directory, including when a tuple is reused.
func SetReassemblyLogger ¶
SetReassemblyLogger configures the logger for this package.
func TransportQualification ¶ added in v0.16.0
Types ¶
type NetworkDataFragment ¶
type NetworkDataFragment interface {
Raw() []byte
CaptureInfo() gopacket.CaptureInfo
Network() gopacket.Flow
Direction() reassembly.TCPFlowDirection
}
NetworkDataFragment represents a single network-layer packet fragment This interface allows the network package to pass data without circular imports
type NetworkDataFragments ¶
type NetworkDataFragments []NetworkDataFragment
NetworkDataFragments is a slice of network data fragments
type ReadPosition ¶
type ReadPosition struct {
// contains filtered or unexported fields
}
ReadPosition reports where in the capture a line-oriented reader currently is.
Readers driven through a bufio.Reader used to have nothing to timestamp a record with except ConversationInfo.FirstClientPacket, so every FTP command, IMAP response and IRC message in a session carried the time the session opened. A conversation held open for hours collapsed to one instant.
The offset is exact rather than approximate: bytes handed to the buffer, minus what the buffer still holds, minus what bufio has read ahead and not yet returned.
func FragmentReader ¶
func FragmentReader(fragments core.DataFragments, server bool) (*bufio.Reader, *ReadPosition)
FragmentReader reads one contiguous direction while retaining capture offsets.
func (*ReadPosition) FromServer ¶
func (p *ReadPosition) FromServer() bool
FromServer reports whether the current direction is the server's.
func (*ReadPosition) Offset ¶
func (p *ReadPosition) Offset() int
Offset returns how many bytes of the current direction the reader has consumed.
func (*ReadPosition) TCPObservation ¶ added in v0.16.0
func (p *ReadPosition) TCPObservation() string
TCPObservation qualifies post-close wire evidence; it never confirms delivery.
func (*ReadPosition) Timestamp ¶
func (p *ReadPosition) Timestamp() int64
Timestamp returns the capture time of the packet carrying the byte the reader is positioned at, in Unix nanoseconds.
type StreamEvidenceFile ¶
type StreamEvidenceManifest ¶
type StreamEvidenceManifest struct {
Version int `json:"version"`
Protocol string `json:"protocol"`
ConnectionKey string `json:"connectionKey"`
CommunityID string `json:"communityId"`
FirstPacketNs string `json:"firstPacketNs"`
Status string `json:"status"`
Client StreamEvidenceFile `json:"client"`
Server StreamEvidenceFile `json:"server"`
Spans []StreamEvidenceSpan `json:"spans"`
Limitations []string `json:"limitations"`
}
type StreamEvidenceSpan ¶
type StreamEvidenceSpan struct {
Direction string `json:"direction"`
Offset int64 `json:"offset,string"`
Length int `json:"length"`
TimestampNs string `json:"timestampNs"`
MissingBytes int `json:"missingBytes"`
Datagram bool `json:"datagram"`
DiscardedBytes int64 `json:"discardedBytes,omitempty,string"`
DiscardReason string `json:"discardReason,omitempty"`
}
type TransportRun ¶ added in v0.16.0
type TransportRun struct {
Conversation *core.ConversationInfo
Observation string
}
TransportRun is a framing domain bounded by transport qualification changes.
func TransportRuns ¶ added in v0.16.0
func TransportRuns(c *core.ConversationInfo) []TransportRun
TransportRuns preserves each direction's sequence order while merging capture times. A qualification transition breaks both framing and request pairing.