From 0e715d62af9478d58ae4a07bd9ff2967b0d1c429 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 23 May 2018 07:15:27 -0700 Subject: [PATCH] Parse ICMP code and type (#7) * sflow: from packet sample * netflow/ipfix: * field 32 on NetFlow * fields 139, 176, 177, 178,179 on IPFIX * updated protobuf --- goflow.go | 2 +- pb/flow.pb.go | 206 +++++++++++++++++++++++----------------- pb/flow.proto | 3 + producer/producer_nf.go | 20 ++++ producer/producer_sf.go | 6 ++ 5 files changed, 149 insertions(+), 88 deletions(-) diff --git a/goflow.go b/goflow.go index 32431ea..5fd2cbc 100644 --- a/goflow.go +++ b/goflow.go @@ -28,7 +28,7 @@ import ( "bytes" ) -const AppVersion = "GoFlow v2.0.3" +const AppVersion = "GoFlow v2.0.4" var ( FEnable = flag.Bool("netflow", true, "Enable NetFlow") diff --git a/pb/flow.pb.go b/pb/flow.pb.go index 34e8224..2b34670 100644 --- a/pb/flow.pb.go +++ b/pb/flow.pb.go @@ -1,15 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: flow.proto -/* -Package flowprotob is a generated protocol buffer package. - -It is generated from these files: - flow.proto - -It has these top-level messages: - FlowMessage -*/ package flowprotob import proto "github.com/golang/protobuf/proto" @@ -52,7 +43,9 @@ var FlowMessage_FlowType_value = map[string]int32{ func (x FlowMessage_FlowType) String() string { return proto.EnumName(FlowMessage_FlowType_name, int32(x)) } -func (FlowMessage_FlowType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} } +func (FlowMessage_FlowType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_flow_5a1d246279821d1f, []int{0, 0} +} // To be deprecated type FlowMessage_IPType int32 @@ -77,57 +70,83 @@ var FlowMessage_IPType_value = map[string]int32{ func (x FlowMessage_IPType) String() string { return proto.EnumName(FlowMessage_IPType_name, int32(x)) } -func (FlowMessage_IPType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 1} } +func (FlowMessage_IPType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_flow_5a1d246279821d1f, []int{0, 1} +} type FlowMessage struct { - Type FlowMessage_FlowType `protobuf:"varint,1,opt,name=Type,json=type,enum=flowprotob.FlowMessage_FlowType" json:"Type,omitempty"` - TimeRecvd uint64 `protobuf:"varint,2,opt,name=TimeRecvd,json=timeRecvd" json:"TimeRecvd,omitempty"` - SamplingRate uint64 `protobuf:"varint,3,opt,name=SamplingRate,json=samplingRate" json:"SamplingRate,omitempty"` - SequenceNum uint32 `protobuf:"varint,4,opt,name=SequenceNum,json=sequenceNum" json:"SequenceNum,omitempty"` + Type FlowMessage_FlowType `protobuf:"varint,1,opt,name=Type,enum=flowprotob.FlowMessage_FlowType" json:"Type,omitempty"` + TimeRecvd uint64 `protobuf:"varint,2,opt,name=TimeRecvd" json:"TimeRecvd,omitempty"` + SamplingRate uint64 `protobuf:"varint,3,opt,name=SamplingRate" json:"SamplingRate,omitempty"` + SequenceNum uint32 `protobuf:"varint,4,opt,name=SequenceNum" json:"SequenceNum,omitempty"` // Found inside packet - TimeFlow uint64 `protobuf:"varint,5,opt,name=TimeFlow,json=timeFlow" json:"TimeFlow,omitempty"` + TimeFlow uint64 `protobuf:"varint,5,opt,name=TimeFlow" json:"TimeFlow,omitempty"` // Source/destination addresses - SrcIP []byte `protobuf:"bytes,6,opt,name=SrcIP,json=srcIP,proto3" json:"SrcIP,omitempty"` - DstIP []byte `protobuf:"bytes,7,opt,name=DstIP,json=dstIP,proto3" json:"DstIP,omitempty"` - IPversion FlowMessage_IPType `protobuf:"varint,8,opt,name=IPversion,json=iPversion,enum=flowprotob.FlowMessage_IPType" json:"IPversion,omitempty"` + SrcIP []byte `protobuf:"bytes,6,opt,name=SrcIP,proto3" json:"SrcIP,omitempty"` + DstIP []byte `protobuf:"bytes,7,opt,name=DstIP,proto3" json:"DstIP,omitempty"` + IPversion FlowMessage_IPType `protobuf:"varint,8,opt,name=IPversion,enum=flowprotob.FlowMessage_IPType" json:"IPversion,omitempty"` // Size of the sampled packet - Bytes uint64 `protobuf:"varint,9,opt,name=Bytes,json=bytes" json:"Bytes,omitempty"` - Packets uint64 `protobuf:"varint,10,opt,name=Packets,json=packets" json:"Packets,omitempty"` + Bytes uint64 `protobuf:"varint,9,opt,name=Bytes" json:"Bytes,omitempty"` + Packets uint64 `protobuf:"varint,10,opt,name=Packets" json:"Packets,omitempty"` // Routing information - RouterAddr []byte `protobuf:"bytes,11,opt,name=RouterAddr,json=routerAddr,proto3" json:"RouterAddr,omitempty"` - NextHop []byte `protobuf:"bytes,12,opt,name=NextHop,json=nextHop,proto3" json:"NextHop,omitempty"` - NextHopAS uint32 `protobuf:"varint,13,opt,name=NextHopAS,json=nextHopAS" json:"NextHopAS,omitempty"` + RouterAddr []byte `protobuf:"bytes,11,opt,name=RouterAddr,proto3" json:"RouterAddr,omitempty"` + NextHop []byte `protobuf:"bytes,12,opt,name=NextHop,proto3" json:"NextHop,omitempty"` + NextHopAS uint32 `protobuf:"varint,13,opt,name=NextHopAS" json:"NextHopAS,omitempty"` // Autonomous system information - SrcAS uint32 `protobuf:"varint,14,opt,name=SrcAS,json=srcAS" json:"SrcAS,omitempty"` - DstAS uint32 `protobuf:"varint,15,opt,name=DstAS,json=dstAS" json:"DstAS,omitempty"` + SrcAS uint32 `protobuf:"varint,14,opt,name=SrcAS" json:"SrcAS,omitempty"` + DstAS uint32 `protobuf:"varint,15,opt,name=DstAS" json:"DstAS,omitempty"` // Prefix size - SrcNet uint32 `protobuf:"varint,16,opt,name=SrcNet,json=srcNet" json:"SrcNet,omitempty"` - DstNet uint32 `protobuf:"varint,17,opt,name=DstNet,json=dstNet" json:"DstNet,omitempty"` + SrcNet uint32 `protobuf:"varint,16,opt,name=SrcNet" json:"SrcNet,omitempty"` + DstNet uint32 `protobuf:"varint,17,opt,name=DstNet" json:"DstNet,omitempty"` // Interfaces - SrcIf uint32 `protobuf:"varint,18,opt,name=SrcIf,json=srcIf" json:"SrcIf,omitempty"` - DstIf uint32 `protobuf:"varint,19,opt,name=DstIf,json=dstIf" json:"DstIf,omitempty"` + SrcIf uint32 `protobuf:"varint,18,opt,name=SrcIf" json:"SrcIf,omitempty"` + DstIf uint32 `protobuf:"varint,19,opt,name=DstIf" json:"DstIf,omitempty"` // Layer 4 protocol - Proto uint32 `protobuf:"varint,20,opt,name=Proto,json=proto" json:"Proto,omitempty"` + Proto uint32 `protobuf:"varint,20,opt,name=Proto" json:"Proto,omitempty"` // Port for UDP and TCP - SrcPort uint32 `protobuf:"varint,21,opt,name=SrcPort,json=srcPort" json:"SrcPort,omitempty"` - DstPort uint32 `protobuf:"varint,22,opt,name=DstPort,json=dstPort" json:"DstPort,omitempty"` + SrcPort uint32 `protobuf:"varint,21,opt,name=SrcPort" json:"SrcPort,omitempty"` + DstPort uint32 `protobuf:"varint,22,opt,name=DstPort" json:"DstPort,omitempty"` // IP and TCP special flags - IPTos uint32 `protobuf:"varint,23,opt,name=IPTos,json=iPTos" json:"IPTos,omitempty"` - ForwardingStatus uint32 `protobuf:"varint,24,opt,name=ForwardingStatus,json=forwardingStatus" json:"ForwardingStatus,omitempty"` - IPTTL uint32 `protobuf:"varint,25,opt,name=IPTTL,json=iPTTL" json:"IPTTL,omitempty"` - TCPFlags uint32 `protobuf:"varint,26,opt,name=TCPFlags,json=tCPFlags" json:"TCPFlags,omitempty"` + IPTos uint32 `protobuf:"varint,23,opt,name=IPTos" json:"IPTos,omitempty"` + ForwardingStatus uint32 `protobuf:"varint,24,opt,name=ForwardingStatus" json:"ForwardingStatus,omitempty"` + IPTTL uint32 `protobuf:"varint,25,opt,name=IPTTL" json:"IPTTL,omitempty"` + TCPFlags uint32 `protobuf:"varint,26,opt,name=TCPFlags" json:"TCPFlags,omitempty"` // Ethernet information - SrcMac uint64 `protobuf:"varint,27,opt,name=SrcMac,json=srcMac" json:"SrcMac,omitempty"` - DstMac uint64 `protobuf:"varint,28,opt,name=DstMac,json=dstMac" json:"DstMac,omitempty"` - VlanId uint32 `protobuf:"varint,29,opt,name=VlanId,json=vlanId" json:"VlanId,omitempty"` + SrcMac uint64 `protobuf:"varint,27,opt,name=SrcMac" json:"SrcMac,omitempty"` + DstMac uint64 `protobuf:"varint,28,opt,name=DstMac" json:"DstMac,omitempty"` + VlanId uint32 `protobuf:"varint,29,opt,name=VlanId" json:"VlanId,omitempty"` // Layer 3 protocol (IPv4/IPv6/ARP/...) - Etype uint32 `protobuf:"varint,30,opt,name=Etype,json=etype" json:"Etype,omitempty"` + Etype uint32 `protobuf:"varint,30,opt,name=Etype" json:"Etype,omitempty"` + IcmpType uint32 `protobuf:"varint,31,opt,name=IcmpType" json:"IcmpType,omitempty"` + IcmpCode uint32 `protobuf:"varint,32,opt,name=IcmpCode" json:"IcmpCode,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FlowMessage) Reset() { *m = FlowMessage{} } +func (m *FlowMessage) String() string { return proto.CompactTextString(m) } +func (*FlowMessage) ProtoMessage() {} +func (*FlowMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_flow_5a1d246279821d1f, []int{0} +} +func (m *FlowMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FlowMessage.Unmarshal(m, b) +} +func (m *FlowMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FlowMessage.Marshal(b, m, deterministic) +} +func (dst *FlowMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_FlowMessage.Merge(dst, src) +} +func (m *FlowMessage) XXX_Size() int { + return xxx_messageInfo_FlowMessage.Size(m) +} +func (m *FlowMessage) XXX_DiscardUnknown() { + xxx_messageInfo_FlowMessage.DiscardUnknown(m) } -func (m *FlowMessage) Reset() { *m = FlowMessage{} } -func (m *FlowMessage) String() string { return proto.CompactTextString(m) } -func (*FlowMessage) ProtoMessage() {} -func (*FlowMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +var xxx_messageInfo_FlowMessage proto.InternalMessageInfo func (m *FlowMessage) GetType() FlowMessage_FlowType { if m != nil { @@ -339,52 +358,65 @@ func (m *FlowMessage) GetEtype() uint32 { return 0 } +func (m *FlowMessage) GetIcmpType() uint32 { + if m != nil { + return m.IcmpType + } + return 0 +} + +func (m *FlowMessage) GetIcmpCode() uint32 { + if m != nil { + return m.IcmpCode + } + return 0 +} + func init() { proto.RegisterType((*FlowMessage)(nil), "flowprotob.FlowMessage") proto.RegisterEnum("flowprotob.FlowMessage_FlowType", FlowMessage_FlowType_name, FlowMessage_FlowType_value) proto.RegisterEnum("flowprotob.FlowMessage_IPType", FlowMessage_IPType_name, FlowMessage_IPType_value) } -func init() { proto.RegisterFile("flow.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 598 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x93, 0x41, 0x6f, 0xd3, 0x4c, - 0x10, 0x86, 0xbf, 0x7c, 0x24, 0x71, 0x3c, 0x49, 0x5a, 0xb3, 0x94, 0x32, 0x94, 0x52, 0x45, 0x39, - 0x45, 0x54, 0xca, 0x01, 0x2a, 0x24, 0x04, 0x97, 0x94, 0x10, 0x61, 0xd1, 0xba, 0x96, 0x1d, 0x5a, - 0xae, 0x8e, 0xbd, 0x89, 0x22, 0x1c, 0x3b, 0x78, 0x37, 0x29, 0xfd, 0x7d, 0xfc, 0x31, 0x34, 0xb3, - 0x76, 0x5a, 0x90, 0xb8, 0xcd, 0xfb, 0xcc, 0xec, 0xec, 0xce, 0xeb, 0x31, 0xc0, 0x3c, 0xcd, 0x6f, - 0x87, 0xeb, 0x22, 0xd7, 0xb9, 0xe0, 0x98, 0xc3, 0x59, 0xff, 0x97, 0x05, 0xed, 0x49, 0x9a, 0xdf, - 0x5e, 0x4a, 0xa5, 0xa2, 0x85, 0x14, 0x67, 0x50, 0x9f, 0xde, 0xad, 0x25, 0xd6, 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f0, 0xa5, 0x71, 0x6c, 0xcb, 0x8a, 0x6e, - 0xfe, 0x44, 0x3f, 0x02, 0x9e, 0x98, 0x9b, 0x25, 0x89, 0xfe, 0x7b, 0x68, 0x55, 0xff, 0x89, 0xd8, - 0x87, 0xf6, 0xe4, 0xe2, 0xea, 0xe6, 0xab, 0xf7, 0xc5, 0xbb, 0xba, 0xf1, 0x9c, 0xff, 0x44, 0x0b, - 0xea, 0xde, 0xe4, 0xfa, 0x9d, 0x63, 0x0b, 0x9b, 0x9e, 0x3d, 0x71, 0xbf, 0x39, 0x40, 0x61, 0x48, - 0x65, 0x4e, 0xa3, 0x7f, 0x0a, 0x4d, 0xb3, 0x7d, 0xa2, 0x4b, 0x0b, 0xfb, 0xc7, 0x41, 0xd7, 0xdf, - 0x9e, 0x39, 0xf5, 0x32, 0x7a, 0xeb, 0x34, 0xcf, 0x4f, 0xe1, 0x28, 0xce, 0x57, 0xc3, 0x38, 0xcd, - 0x37, 0xc9, 0x3c, 0x8d, 0x0a, 0x39, 0xcc, 0xa4, 0xe6, 0xa5, 0x8e, 0x16, 0x8b, 0xf3, 0xee, 0x83, - 0x95, 0xf6, 0x67, 0xb3, 0x26, 0x7f, 0xa3, 0x37, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xb3, - 0xab, 0x2d, 0x13, 0x04, 0x00, 0x00, +func init() { proto.RegisterFile("flow.proto", fileDescriptor_flow_5a1d246279821d1f) } + +var fileDescriptor_flow_5a1d246279821d1f = []byte{ + // 580 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xd1, 0x73, 0xd2, 0x40, + 0x10, 0xc6, 0x45, 0x29, 0x85, 0xa3, 0xb4, 0xf1, 0xac, 0x75, 0xc5, 0x8a, 0x19, 0x9e, 0x18, 0x3b, + 0xc3, 0x83, 0x76, 0x9c, 0x71, 0xf4, 0x05, 0x8a, 0x19,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 0x5c, 0x2b, 0x09, 0xe2, 0x1c, 0xda, 0x94, 0xd8, 0x72, + 0x31, 0x99, 0xeb, 0x20, 0x84, 0x57, 0xf4, 0xdb, 0x0a, 0x2a, 0x26, 0x83, 0xfa, 0xb9, 0xd6, 0x35, + 0xa1, 0x7e, 0x9b, 0x04, 0xa9, 0x1d, 0xc1, 0x6b, 0x3d, 0x31, 0x4d, 0x78, 0xf3, 0x17, 0x85, 0x6b, + 0xd3, 0xd1, 0x37, 0x13, 0xe0, 0xcd, 0x76, 0xb8, 0x58, 0xd2, 0x3e, 0xbd, 0xd1, 0x37, 0x97, 0x5c, + 0xe6, 0xae, 0x64, 0x24, 0xc0, 0xdc, 0xe5, 0x90, 0xbb, 0x9f, 0x58, 0xbd, 0xdc, 0x2f, 0x7e, 0xc2, + 0x9a, 0xd6, 0xf8, 0xe6, 0xee, 0xbb, 0xf3, 0xcd, 0xb9, 0xb9, 0x73, 0x8c, 0x47, 0xbc, 0xce, 0xaa, + 0x8e, 0x75, 0xfb, 0xd1, 0x68, 0xf0, 0x06, 0xb6, 0x6b, 0xd9, 0x3f, 0x0c, 0x86, 0xa1, 0x8f, 0x65, + 0xc6, 0x41, 0xf7, 0x82, 0xd5, 0xf4, 0xab, 0xe5, 0x2d, 0x7c, 0xe8, 0x0f, 0x0e, 0xda, 0xee, 0xfa, + 0xd2, 0xa8, 0x16, 0xd1, 0x07, 0xa3, 0x36, 0xbc, 0x60, 0xed, 0x50, 0x2e, 0xfa, 0x61, 0x22, 0x57, + 0xd1, 0x2c, 0x09, 0x32, 0xd1, 0x4f, 0x85, 0xa2, 0x65, 0x08, 0xe2, 0x78, 0xd8, 0xda, 0x5b, 0x05, + 0x77, 0x3a, 0xad, 0xd1, 0x82, 0xbc, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x39, 0xb6, 0xe1, 0x29, + 0x4b, 0x04, 0x00, 0x00, } diff --git a/pb/flow.proto b/pb/flow.proto index 4bb1913..81a68e4 100644 --- a/pb/flow.proto +++ b/pb/flow.proto @@ -75,4 +75,7 @@ message FlowMessage { // Layer 3 protocol (IPv4/IPv6/ARP/...) uint32 Etype = 30; + + uint32 IcmpType = 31; + uint32 IcmpCode = 32; } \ No newline at end of file diff --git a/producer/producer_nf.go b/producer/producer_nf.go index fa1529a..f2352cd 100644 --- a/producer/producer_nf.go +++ b/producer/producer_nf.go @@ -223,6 +223,26 @@ func ConvertNetFlowDataSet(version uint16, baseTime uint32, uptime uint32, recor flowMessage.IPversion = flowmessage.FlowMessage_IPv6 flowMessage.NextHop = v + // ICMP + case netflow.NFV9_FIELD_ICMP_TYPE: + var icmpTypeCode uint16 + DecodeUNumber(v, &icmpTypeCode) + flowMessage.IcmpType = uint32(icmpTypeCode>>8) + flowMessage.IcmpCode = uint32(icmpTypeCode&0xff) + case netflow.IPFIX_FIELD_icmpTypeCodeIPv6: + var icmpTypeCode uint16 + DecodeUNumber(v, &icmpTypeCode) + flowMessage.IcmpType = uint32(icmpTypeCode>>8) + flowMessage.IcmpCode = uint32(icmpTypeCode&0xff) + case netflow.IPFIX_FIELD_icmpTypeIPv4: + DecodeUNumber(v, &(flowMessage.IcmpType)) + case netflow.IPFIX_FIELD_icmpTypeIPv6: + DecodeUNumber(v, &(flowMessage.IcmpType)) + case netflow.IPFIX_FIELD_icmpCodeIPv4: + DecodeUNumber(v, &(flowMessage.IcmpCode)) + case netflow.IPFIX_FIELD_icmpCodeIPv6: + DecodeUNumber(v, &(flowMessage.IcmpCode)) + // Mac case netflow.NFV9_FIELD_IN_SRC_MAC: DecodeUNumber(v, &(flowMessage.SrcMac)) diff --git a/producer/producer_sf.go b/producer/producer_sf.go index 22ad36a..3cc6990 100644 --- a/producer/producer_sf.go +++ b/producer/producer_sf.go @@ -89,6 +89,12 @@ func ParseSampledHeader(flowMessage *flowmessage.FlowMessage, sampledHeader *sfl tcpflags = dataTransport[13] } + // ICMP and ICMPv6 + if len(dataTransport) >= 2 && (nextHeader == 1 || nextHeader == 58) { + (*flowMessage).IcmpType = uint32(dataTransport[0]) + (*flowMessage).IcmpCode = uint32(dataTransport[1]) + } + (*flowMessage).SrcIP = srcIP (*flowMessage).DstIP = dstIP (*flowMessage).Proto = uint32(nextHeader)