Exemplo n.º 1
0
        public void FilterPackets(string filterText)
        {
            var filters = filterText.Split(',', ';').ToList();

            _destinationFilter = _sourceFilter = _protocolFilter = string.Empty;
            foreach (var filter in filters)
            {
                if (filter.Contains("dest:"))
                {
                    _destinationFilter = new string(filter.Skip(filter.IndexOf(':') + 1).ToArray());
                }
                if (filter.Contains("source:"))
                {
                    _sourceFilter = new string(filter.Skip(filter.IndexOf(':') + 1).ToArray());
                }
                if (filter.Contains("protocol:"))
                {
                    _protocolFilter = new string(filter.Skip(filter.IndexOf(':') + 1).ToArray());
                }
            }

            FilteredPackets.Clear();
            foreach (var p in Packets)
            {
                if (p.Destination.Contains(_destinationFilter) && p.Source.Contains(_sourceFilter) && p.Protocol.ToString().Contains(_protocolFilter))
                {
                    FilteredPackets.Add(p);
                }
            }
        }
Exemplo n.º 2
0
        public void AddToPackets(PacketType type, byte[] data)
        {
            var packet = new Packet(type, data);

            Application.Current.Dispatcher.Invoke(delegate
            {
                Packets.Add(packet);
            });

            var filterType = (PacketType)(SelectedPacketTypeIndex - 1);

            if (filterType == type || SelectedPacketTypeIndex == 0)
            {
                if (_filterOpCode > 0)
                {
                    if (_filterOpCode == packet.OpCode)
                    {
                        Application.Current.Dispatcher.Invoke(delegate
                        {
                            FilteredPackets.Add(packet);
                        });
                    }
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        FilteredPackets.Add(packet);
                    });
                }
            }
        }
Exemplo n.º 3
0
        public async Task StartSniff()
        {
            while (true)
            {
                var p = await _sniffer.SniffAsync();

                Packets.Add(p);
                if (p.Destination.Contains(_destinationFilter) && p.Source.Contains(_sourceFilter) && p.Protocol.ToString().Contains(_protocolFilter))
                {
                    FilteredPackets.Add(p);
                }
            }
        }