Beispiel #1
0
        private DateTime ParseTime(JsonPacket jsonPacket)
        {
            string   format = "MMM dd, yyyy HH:mm:ss";
            DateTime dateTime;

            DateTime.TryParseExact(jsonPacket._source.layers.frame.frame_time.Substring(0, 21), format, new CultureInfo("en-US"), DateTimeStyles.None, out dateTime);

            return(dateTime);
        }
Beispiel #2
0
 private string ParseLength(JsonPacket jsonPacket)
 {
     if (jsonPacket?._source?.layers?.tcp != null)
     {
         return(jsonPacket._source.layers.tcp.tcp_len);
     }
     if (jsonPacket?._source?.layers?.udp != null)
     {
         return(jsonPacket._source.layers.udp.udp_length);
     }
     return("UNKNOWN");
 }
Beispiel #3
0
 private string ParseDestPort(JsonPacket jsonPacket)
 {
     if (jsonPacket?._source?.layers?.tcp != null)
     {
         return(jsonPacket?._source?.layers?.tcp?.tcp_dstport);
     }
     if (jsonPacket?._source?.layers?.udp != null)
     {
         return(jsonPacket?._source?.layers?.udp?.udp_dstport);
     }
     return("UNKNOWN");
 }
Beispiel #4
0
 public Packet ConvertJsonPacket(JsonPacket jsonPacket)
 {
     return(new Packet
     {
         Protocol = ParseProtocol(jsonPacket),
         Length = ParseLength(jsonPacket),
         Time = ParseTime(jsonPacket),
         Source_MAC = ParseSourceMAC(jsonPacket),
         Source_IP = ParseSourceIP(jsonPacket),
         Source_Port = ParseSourcePort(jsonPacket),
         Dest_MAC = ParseDestMAC(jsonPacket),
         Dest_IP = ParseDestIP(jsonPacket),
         Dest_Port = ParseDestPort(jsonPacket)
     });
 }
Beispiel #5
0
 private string ParseProtocol(JsonPacket jsonPacket)
 {
     if (jsonPacket._source.layers.tcp != null)
     {
         return("TCP");
     }
     if (jsonPacket._source.layers.udp != null)
     {
         return("UDP");
     }
     if (jsonPacket._source.layers.icmpv6 != null)
     {
         return("ICMPv6");
     }
     if (jsonPacket._source.layers.arp != null)
     {
         return("ARP");
     }
     return("UNKNOWN");
 }
Beispiel #6
0
 private string ParseSourceIP(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.ip?.ip_src);
 }
Beispiel #7
0
 private string ParseDestMAC(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.eth?.eth_dst);
 }
Beispiel #8
0
 private string ParseSourceMAC(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.eth?.eth_src);
 }
Beispiel #9
0
 private string ParseDestIP(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.ip?.ip_dst);
 }