Esempio n. 1
0
        private void LoadFile(string filename)
        {
            using (var pCap = new PCapFile(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
            {
                lock (DataPacketsLock)
                {
                    DataPackets = pCap.Where(p => p.PacketType != PCapPacketType.Other && !(p.IsBaseIpProtocol ||
                                                                                            (p.PortSource == 0 && p.PortDestination == 0) ||
                                                                                            p.Data == null ||
                                                                                            p.Data.Length == 0)).ToList();
                    //DataPackets = pCap.ToList();

                    // Clear statistics
                    searchStats.Clear();
                    DataPackets.ForEach(row =>
                    {
                        if (SearchStats.IsSearchPacket(row))
                        {
                            searchStats.Add(row);
                        }
                    });
                }
                txtFilter.Text = "";
                ShowDataPacket();
            }
        }
Esempio n. 2
0
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);

            scrollPanel     = this.FindControl <Panel>("scrollPanel");
            detailContainer = this.FindControl <Panel>("detailContainer");
            txtFilter       = this.FindControl <TextBox>("txtFilter");
            mnuStopCapture  = this.FindControl <MenuItem>("mnuStopCapture");
            searchStats     = this.FindControl <SearchStats>("searchStats");
            this.KeyDown   += MainWindow_KeyDown;
        }
Esempio n. 3
0
        private void Sniffer_ReceivedPacket(NetworkSniffer sniffer, PCapPacket packet)
        {
            if (DataPackets == null)
            {
                DataPackets = new List <PCapPacket>();
            }
            if (packet.PacketType != PCapPacketType.Other && !(packet.IsBaseIpProtocol ||
                                                               (packet.PortSource == 0 && packet.PortDestination == 0) ||
                                                               packet.Data == null ||
                                                               packet.Data.Length == 0))
            {
                lock (DataPacketsLock)
                {
                    DataPackets.Add(packet);
                }

                if (SearchStats.IsSearchPacket(packet))
                {
                    searchStats.Add(packet);
                }

                // Does the new packet match the filter?
                var filter = txtFilter.Text?.ToLower() ?? "";
                if (packet.Source.Contains(filter) ||
                    packet.Destination.Contains(filter) ||
                    packet.PacketType.ToString().ToLower().Contains(filter) ||
                    packet.PacketNumber.ToString().Contains(filter))
                {
                    Avalonia.Threading.Dispatcher.UIThread.Post(() =>
                    {
                        var item = new PacketListItem
                        {
                            PacketNumber      = packet.PacketNumber,
                            PacketSource      = packet.Source,
                            PacketDestination = packet.Destination,
                            PacketProtocol    = packet.PacketType.ToString(),
                            PacketLength      = packet.Data.Length,
                            Packet            = packet,
                            Foreground        = Colorize(packet.Data)
                        };
                        item.Click += Item_Click;
                        scrollPanel.Children.Add(item);
                    });
                }
            }
        }