Пример #1
0
 public void SniffStream()
 {
     byte[] array = this.GetPayloadStream(null, 1024).ToArray();
     if (Utilities.IsNullOrEmpty(array))
     {
         this.ctContentType = TCPStreamContent.NoPayload;
         return;
     }
     if (array.Length > 2 && 22 == array[0] && 3 == array[1])
     {
         this.ctContentType = TCPStreamContent.SSLTLS;
         return;
     }
     if (array[0] < 65 || array[0] > 122 || (array[0] > 90 && array[0] < 97))
     {
         this.ctContentType = TCPStreamContent.Unknown;
         return;
     }
     if (Utilities.HasMagicBytes(array, "HTTP/"))
     {
         this.ctContentType = (TCPStreamContent.Server | TCPStreamContent.HTTP);
         return;
     }
     this.ctContentType = (TCPStreamContent.Client | TCPStreamContent.HTTP);
 }
Пример #2
0
        private static Session[] _DumpTCPTraffic(Dictionary <string, TCPStream> dictTCP)
        {
            List <Session> list = new List <Session>();

            foreach (KeyValuePair <string, TCPStream> current in dictTCP)
            {
                TCPStream value    = current.Value;
                TCPStream tcpsPeer = current.Value.tcpsPeer;
                if (tcpsPeer == null || tcpsPeer.IsServer)
                {
                    TCPStreamContent tCPStreamContent = current.Value.ctContentType & ~(TCPStreamContent.Client | TCPStreamContent.Server);
                    if (tCPStreamContent != TCPStreamContent.HTTP)
                    {
                        if (tCPStreamContent == TCPStreamContent.SSLTLS)
                        {
                            list.AddRange(PacketCaptureImport.GetHTTPSHandshakeFromStreams(value, tcpsPeer));
                        }
                    }
                    else
                    {
                        list.AddRange(PacketCaptureImport.GetSessionsFromStreams(value, tcpsPeer));
                    }
                }
            }
            list.Sort((Session a, Session b) => a.Timers.ClientBeginRequest.CompareTo(b.Timers.ClientBeginRequest));
            foreach (Session current2 in list)
            {
                current2.state = (SessionStates)11;
            }
            return(list.ToArray());
        }