Esempio n. 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);
        }
Esempio n. 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");
 }
Esempio n. 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");
 }
Esempio n. 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)
     });
 }
Esempio n. 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");
 }
Esempio n. 6
0
 private string ParseSourceIP(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.ip?.ip_src);
 }
Esempio n. 7
0
 private string ParseDestMAC(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.eth?.eth_dst);
 }
Esempio n. 8
0
 private string ParseSourceMAC(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.eth?.eth_src);
 }
Esempio n. 9
0
 private string ParseDestIP(JsonPacket jsonPacket)
 {
     return(jsonPacket?._source?.layers?.ip?.ip_dst);
 }