|
| 1 | +/* |
| 2 | +Package silk is written without cgo to read common silk file formats. |
| 3 | +
|
| 4 | +What is silk? |
| 5 | +
|
| 6 | +https://tools.netsa.cert.org/silk/faq.html#what-silk |
| 7 | +
|
| 8 | + "SiLK is a suite of network traffic collection and analysis tools developed and |
| 9 | + maintained by the CERT Network Situational Awareness Team (CERT NetSA) at |
| 10 | + Carnegie Mellon University to facilitate security analysis of large networks. |
| 11 | + The SiLK tool suite supports the efficient collection, storage, and analysis |
| 12 | + of network flow data, enabling network security analysts to rapidly query |
| 13 | + large historical traffic data sets." |
| 14 | +
|
| 15 | +
|
| 16 | +Example: |
| 17 | +
|
| 18 | + import ( |
| 19 | + "fmt" |
| 20 | + "log" |
| 21 | + "silk" |
| 22 | + ) |
| 23 | +
|
| 24 | + func main() { |
| 25 | +
|
| 26 | + var testFile = "testdata/FT_RWIPV6-v2-c0-L.dat" |
| 27 | + var err error |
| 28 | + var sf silk.File |
| 29 | +
|
| 30 | + if sf, err = silk.OpenFile(testFile); err != nil { |
| 31 | + log.Fatalf("OpenFile() error:%s", err) |
| 32 | + } |
| 33 | +
|
| 34 | + log.Printf("Compression:%d", sf.Header.Compression) |
| 35 | + log.Printf("FileFlags:%d", sf.Header.FileFlags) |
| 36 | + log.Printf("FileVersion:%d", sf.Header.FileVersion) |
| 37 | + log.Printf("HeaderLength:%d", sf.Header.HeaderLength) |
| 38 | + log.Printf("MagicNumber:%x", sf.Header.MagicNumber) |
| 39 | + log.Printf("RecordFormat:%d", sf.Header.RecordFormat) |
| 40 | + log.Printf("RecordSize:%d", sf.Header.RecordSize) |
| 41 | + log.Printf("RecordVersion:%d", sf.Header.RecordVersion) |
| 42 | + log.Printf("SilkVersion:%d", sf.Header.SilkVersion) |
| 43 | +
|
| 44 | + log.Printf("File record count:%d\n", len(sf.Flows)) |
| 45 | +
|
| 46 | + fmt.Printf("start_time_ms,src_ip,dst_ip,src_port,dst_port\n") |
| 47 | + for _, flow := range sf.Flows { |
| 48 | + fmt.Printf("%d,%s,%s,%d,%d\n", |
| 49 | + flow.StartTimeMS, |
| 50 | + flow.SrcIP.String(), |
| 51 | + flow.DstIP.String(), |
| 52 | + flow.SrcPort, |
| 53 | + flow.DstPort, |
| 54 | + ) |
| 55 | + //Etc... for other silk.Flow values |
| 56 | + } |
| 57 | + } |
| 58 | +
|
| 59 | +*/ |
| 60 | +package silk |
0 commit comments