Documentation ¶
Overview ¶
Package silk is written without cgo to read common silk file formats.
What is silk?
https://tools.netsa.cert.org/silk/faq.html#what-silk
"SiLK is a suite of network traffic collection and analysis tools developed and maintained by the CERT Network Situational Awareness Team (CERT NetSA) at Carnegie Mellon University to facilitate security analysis of large networks. The SiLK tool suite supports the efficient collection, storage, and analysis of network flow data, enabling network security analysts to rapidly query large historical traffic data sets."
Example:
import ( "fmt" "log" "silk" ) func main() { var testFile = "testdata/FT_RWIPV6-v2-c0-L.dat" var err error var sf silk.File if sf, err = silk.OpenFile(testFile); err != nil { log.Fatalf("OpenFile() error:%s", err) } log.Printf("Compression:%d", sf.Header.Compression) log.Printf("FileFlags:%d", sf.Header.FileFlags) log.Printf("FileVersion:%d", sf.Header.FileVersion) log.Printf("HeaderLength:%d", sf.Header.HeaderLength) log.Printf("MagicNumber:%x", sf.Header.MagicNumber) log.Printf("RecordFormat:%d", sf.Header.RecordFormat) log.Printf("RecordSize:%d", sf.Header.RecordSize) log.Printf("RecordVersion:%d", sf.Header.RecordVersion) log.Printf("SilkVersion:%d", sf.Header.SilkVersion) log.Printf("File record count:%d\n", len(sf.Flows)) fmt.Printf("start_time_ms,src_ip,dst_ip,src_port,dst_port\n") for _, flow := range sf.Flows { fmt.Printf("%d,%s,%s,%d,%d\n", flow.StartTimeMS, flow.SrcIP.String(), flow.DstIP.String(), flow.SrcPort, flow.DstPort, ) //Etc... for other silk.Flow values } }
Index ¶
Constants ¶
const SilkTCPStateExpanded uint8 = 0x01
SilkTCPStateExpanded constant value defined in silk code
Variables ¶
var ErrUnsupportedCompression = fmt.Errorf("Unsupported compression")
ErrUnsupportedCompression unknown compression type. Currently supported
0 = no compression 1 = zlib 2 = lzo 3 = snappy
var ErrUnsupportedPartialRead = fmt.Errorf("Reader failed to read expected length")
Functions ¶
Types ¶
type ChannelFlowReceiver ¶ added in v1.2.0
type ChannelFlowReceiver struct { Header Header // contains filtered or unexported fields }
func NewChannelFlowReceiver ¶ added in v1.2.0
func NewChannelFlowReceiver(channelBufferSize int) *ChannelFlowReceiver
func (*ChannelFlowReceiver) Close ¶ added in v1.2.0
func (c *ChannelFlowReceiver) Close()
func (*ChannelFlowReceiver) HandleFlow ¶ added in v1.2.0
func (c *ChannelFlowReceiver) HandleFlow(f Flow)
func (*ChannelFlowReceiver) HandleHeader ¶ added in v1.2.0
func (c *ChannelFlowReceiver) HandleHeader(h Header)
func (ChannelFlowReceiver) Read ¶ added in v1.2.0
func (c ChannelFlowReceiver) Read() <-chan Flow
type File ¶
File contains header and silk slice of flow records
func ParseReader ¶ added in v1.1.0
func ParseReader(r io.Reader, receiver FlowReceiver) (sf File, err error)
type Flow ¶
type Flow struct { StartTimeMS uint64 Duration uint32 SrcIP net.IP DstIP net.IP SrcPort uint16 DstPort uint16 Proto uint8 Flags uint8 Packets uint32 Bytes uint32 ClassType uint8 Sensor uint16 InitalFlags uint8 SessionFlags uint8 Attributes uint8 Application uint16 SNMPIn uint16 SNMPOut uint16 NextHopIP net.IP // contains filtered or unexported fields }
Flow represents a silk flow row of data Depending on type of silk record not all fields are used More details on the Flow stuct fields can be found here:
https://tools.netsa.cert.org/silk/faq.html#file-formats
type FlowReceiver ¶ added in v1.2.0
type Header ¶
type Header struct { MagicNumber []byte FileFlags uint8 RecordFormat uint8 FileVersion uint8 Compression uint8 SilkVersion uint32 RecordSize uint16 RecordVersion uint16 VarLenHeaders []VarLenHeader HeaderLength int // contains filtered or unexported fields }
Header is documented here:
https://tools.netsa.cert.org/silk/faq.html#file-header
type SliceFlowReceiver ¶ added in v1.2.0
type SliceFlowReceiver struct {
File
}
func NewSliceFlowReceiver ¶ added in v1.2.0
func NewSliceFlowReceiver(initialSize int) *SliceFlowReceiver
func (*SliceFlowReceiver) Close ¶ added in v1.2.0
func (a *SliceFlowReceiver) Close()
func (*SliceFlowReceiver) HandleFlow ¶ added in v1.2.0
func (a *SliceFlowReceiver) HandleFlow(f Flow)
func (*SliceFlowReceiver) HandleHeader ¶ added in v1.2.0
func (a *SliceFlowReceiver) HandleHeader(h Header)
type VarLenHeader ¶
VarLenHeader is part of the silk header. They contain different things like the cli command used to create the file. For some file types the variable length header also contains the year/month/day/hour of the file.