Пример #1
0
        public void DecodeSSLCommunication(string filename)
        {
            var frameKeyProvider = new FrameKeyProvider();

            Console.WriteLine($"Test file={filename}:");
            var packets = PacketProvider.LoadPacketsFromResourceFolder(filename).Select(p => new FrameData {
                Data = p.Data, LinkLayer = (LinkLayerType)p.LinkLayerType, Timestamp = 0
            });
            var flows = from packet in packets.Select(p => (Key: frameKeyProvider.GetKey(p), Packet: p))
                        group packet by packet.Key;

            foreach (var flow in flows.Where(x => IsTlsFlow(x.Key)))
            {
                Console.WriteLine($"{flow.Key}:");
                foreach (var msg in flow)
                {
                    var  tcpPacket = ParseTcpPacket(msg.Packet);
                    var  tlsPacket = ParseTlsPacket(tcpPacket);
                    bool emptyTcp  = (tcpPacket.PayloadData?.Length ?? 0) == 0;

                    var flags   = TcpFlags(tcpPacket);
                    var tlsInfo = $"[TLS: Type={tlsPacket?.ContentType.ToString()}]";
                    Console.WriteLine($"  {msg.Key}: {(!emptyTcp ? tlsInfo : "")} [TCP: PayloadSize={tcpPacket?.PayloadData?.Length}, Flags={flags}]");
                }
            }
        }
Пример #2
0
        public void LoadAndParsePacket(string filename)
        {
            var packets = PacketProvider.LoadPacketsFromResourceFolder(filename);
            var flows   = from packet in packets.Select(p => (Key: FrameKeyProvider.GetKeyForEthernetFrame(p.Data), Packet: p))
                          group packet by packet.Key;

            foreach (var flow in flows)
            {
                var httpFlow = flow.Select(x => (x.Key, ParseHttpPacket(x.Packet)));
                foreach (var msg in httpFlow)
                {
                    Console.WriteLine($"{msg.Key}: {msg.Item2.PacketType}");
                }
            }
        }