virtual PPacket Parsing(Packet packet, TimeSpan time, int len) { System.Net.IPAddress srcIp, dstIp = null; var adpPacket = packet.Extract <UdpPacket>(); var ether = packet.Extract <EthernetPacket>(); var icmpPacket = packet.Extract <IPv4Packet>(); if (icmpPacket != null) { srcIp = icmpPacket.SourceAddress; dstIp = icmpPacket.DestinationAddress; } else { var icmpPacketv6 = packet.Extract <IPv6Packet>(); srcIp = icmpPacketv6.SourceAddress; dstIp = icmpPacketv6.DestinationAddress; } int srcPort = adpPacket.SourcePort; int dstPort = adpPacket.DestinationPort; PPacket protocol = new PPacket("UDP", Convert.ToString(time.Hours) + ":" + Convert.ToString(time.Minutes) + ":" + Convert.ToString(time.Seconds) + " " + Convert.ToString(time.Milliseconds), Convert.ToString(len), Convert.ToString(srcIp), Convert.ToString(dstIp), Convert.ToString(srcPort), Convert.ToString(dstPort), "-"); return(protocol); }
virtual PPacket Parsing(Packet packet, TimeSpan time, int len) { var tcpPacket = packet.Extract <TcpPacket>(); var ipPacket = (IPPacket)tcpPacket.ParentPacket; System.Net.IPAddress srcIp = ipPacket.SourceAddress; System.Net.IPAddress dstIp = ipPacket.DestinationAddress; int srcPort = tcpPacket.SourcePort; int dstPort = tcpPacket.DestinationPort; PPacket protocol = new PPacket("TCP", Convert.ToString(time.Hours) + ":" + Convert.ToString(time.Minutes) + ":" + Convert.ToString(time.Seconds) + " " + Convert.ToString(time.Milliseconds), Convert.ToString(len), Convert.ToString(srcIp), Convert.ToString(dstIp), Convert.ToString(srcPort), Convert.ToString(dstPort), "-"); return(protocol); }
virtual PPacket Parsing(Packet packet, TimeSpan time, int len) { var tcpPacket = packet.Extract <TcpPacket>(); var words = Encoding.UTF8.GetString(tcpPacket.PayloadData).Split('\n'); var ipPacket = (IPPacket)tcpPacket.ParentPacket; System.Net.IPAddress srcIp = ipPacket.SourceAddress; System.Net.IPAddress dstIp = ipPacket.DestinationAddress; int srcPort = tcpPacket.SourcePort; int dstPort = tcpPacket.DestinationPort; PPacket protocol = new PPacket("HTTP", Convert.ToString(time.Hours) + ":" + Convert.ToString(time.Minutes) + ":" + Convert.ToString(time.Seconds) + " " + Convert.ToString(time.Milliseconds), Convert.ToString(len), Convert.ToString(srcIp), Convert.ToString(dstIp), Convert.ToString(srcPort), Convert.ToString(dstPort), Convert.ToString(words[0])); return(protocol); }
virtual PPacket Parsing(Packet packet, TimeSpan time, int len) { var ethernetPacket = packet.Extract <PacketDotNet.EthernetPacket>(); var arpPacket = packet.Extract <PacketDotNet.ArpPacket>(); System.Net.IPAddress srcId = null, dstId = null; System.Net.NetworkInformation.PhysicalAddress srcPort = ethernetPacket.SourceHardwareAddress; System.Net.NetworkInformation.PhysicalAddress dstPort = ethernetPacket.DestinationHardwareAddress; if (arpPacket != null) { dstId = arpPacket.TargetProtocolAddress; srcId = arpPacket.SenderProtocolAddress; } PPacket protocol = new PPacket("Ethernet", Convert.ToString(time.Hours) + ":" + Convert.ToString(time.Minutes) + ":" + Convert.ToString(time.Seconds) + " " + Convert.ToString(time.Milliseconds), Convert.ToString(len), Convert.ToString(srcId), Convert.ToString(dstId), Convert.ToString(srcPort), Convert.ToString(dstPort), "-"); return(protocol); }
virtual PPacket Parsing(Packet packet, TimeSpan time, int len) { var icmpPacket = packet.Extract <IPv4Packet>(); if (icmpPacket == null) { var icmpPacketv6 = packet.Extract <IPv6Packet>(); System.Net.IPAddress srcIp = icmpPacketv6.SourceAddress; System.Net.IPAddress dstIp = icmpPacketv6.DestinationAddress; PPacket protocol = new PPacket("ICMPv6", Convert.ToString(time.Hours) + ":" + Convert.ToString(time.Minutes) + ":" + Convert.ToString(time.Seconds) + " " + Convert.ToString(time.Milliseconds), Convert.ToString(len), Convert.ToString(srcIp), Convert.ToString(dstIp), "-", "-", "-"); return(protocol); } else { System.Net.IPAddress srcIp = icmpPacket.SourceAddress; System.Net.IPAddress dstIp = icmpPacket.DestinationAddress; PPacket protocol = new PPacket("ICMPv4", Convert.ToString(time.Hours) + ":" + Convert.ToString(time.Minutes) + ":" + Convert.ToString(time.Seconds) + " " + Convert.ToString(time.Milliseconds), Convert.ToString(len), Convert.ToString(srcIp), Convert.ToString(dstIp), "-", "-", "-"); return(protocol); } }
public void Add(PPacket protocol) { listOfProtocols.Add(protocol); }