コード例 #1
0
        public void OpenDetailsInNewTab(PacketViewModel packet)
        {
            var packetDetailsDocumentItem = this.packetDetailsDocumentItemVMFactory.Create();

            packetDetailsDocumentItem.PacketDetails.Packet = packet;
            this.bus.Publish(new ItemOpenedEvent(packetDetailsDocumentItem));
        }
コード例 #2
0
        public void FilterAndParseTest()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            string filepath = "../../../../TestFiles/test.pcap";

            bool listChanged = false;

            _model.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
            {
                listChanged = true;
            };

            PacketViewModel packet             = new PacketViewModel(GetPacketExample());
            BindingList <PacketViewModel> list = new BindingList <PacketViewModel>()
            {
                packet
            };

            _model.Packets = list;
            Assert.That(_model.Packets, Is.EqualTo(list));

            _model.Filter(null, new FilterParameters());
            _model.Parse(null, filepath);

            Assert.True(listChanged);
        }
コード例 #3
0
 public object?Evaluate(PacketViewModel entity)
 {
     lexer.Reset();
     tokens.Reset();
     parser.Reset();
     visitor.SetContext(entity);
     return(visitor.Visit(parser.expr()));
 }
コード例 #4
0
        public async Task <PacketViewModel> UpdateAsync(PacketViewModel packetViewModel)
        {
            var newPacket = new Packet {
                Id     = packetViewModel.Id,
                Name   = packetViewModel.Name,
                ImgUrl = packetViewModel.ImgUri
            };
            await _PacketRepository.updateAsync(newPacket);

            return(packetViewModel);
        }
コード例 #5
0
        public async Task <IActionResult> OnGet(int id)
        {
            packetFeaturesViewMode = await _packetFeatureService.GetPacketWithFeaturesAsync(id);

            packetViewModel = new PacketViewModel {
                Id     = packetFeaturesViewMode.Id,
                Name   = packetFeaturesViewMode.Name,
                ImgUri = packetFeaturesViewMode.ImgUri
            };

            return(Page());
        }
コード例 #6
0
        public void InitTest()
        {
            Packet          packet = GetPacketExample();
            PacketViewModel model  = new PacketViewModel(packet);

            Assert.That(model.Packet, Is.EqualTo(packet));
            Assert.That(model.Data, Is.EqualTo("00 01 02 03 04 05 06 07    08 09 00 0B 15 2C 41 2C\r\n0B 15 2C 41 2C "));
            Assert.That(model.Header, Is.EqualTo(packet.Header));
            Assert.That(model.DestinationAddress, Is.EqualTo(packet.DestinationAddress));
            Assert.That(model.DestinationPort, Is.EqualTo(packet.DestinationPort));
            Assert.That(model.SourceAddress, Is.EqualTo(packet.SourceAddress));
            Assert.That(model.SourcePort, Is.EqualTo(packet.SourcePort));
            Assert.That(model.Length, Is.EqualTo(packet.Length.ToString()));
            Assert.That(model.TimeStamp, Is.EqualTo(packet.TimeStamp.ToString()));
            Assert.That(model.Protocol, Is.EqualTo(packet.Protocol));
        }
コード例 #7
0
        public IEnumerable <IProperty> Create(PacketViewModel packet)
        {
            Contract.Requires <ArgumentNullException>(packet != null);

            Message message = null;
            SerializationContext serializationContext = null;

            try
            {
                message = this.messageSerializerService.Deserialize(packet.Packet, out serializationContext);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("bork: Deserialization fail!: " + ex.Message);
            }

            var list = new List <IProperty>();

            if (message != null)
            {
                var headerProperties = this.CreateHeaderProperties(message, packet.Packet);
                var bodyProperties   = this.CreateProperties(serializationContext, packet.Packet);

                var headerRoot = new PropertyViewModel(
                    this.messagePropertyInfos[0], 0, 16, message, new ArraySegment <byte>(packet.Packet, 0, 16));
                foreach (var property in headerProperties)
                {
                    headerRoot.AddProperty(property);
                }

                var bodyRoot = new PropertyViewModel(
                    this.messagePropertyInfos[1],
                    16,
                    packet.Packet.Length - 16,
                    message,
                    new ArraySegment <byte>(packet.Packet, 16, packet.Packet.Length - 16));
                foreach (var property in bodyProperties)
                {
                    bodyRoot.AddProperty(property);
                }

                list.Add(headerRoot);
                list.Add(bodyRoot);
            }

            return(list);
        }
コード例 #8
0
        public void HeaderAndDataTest()
        {
            PacketViewModel packet             = new PacketViewModel(GetPacketExample());
            BindingList <PacketViewModel> list = new BindingList <PacketViewModel>()
            {
                packet
            };

            _model.Packets = list;
            Assert.That(_model.Packets, Is.EqualTo(list));

            _model.UpdateHeaderAndData(new SelectedItemInList {
                ItemPosition = 0
            });
            Assert.That(_model.CurrentData, Is.EqualTo(packet.Data));
            Assert.That(_model.CurrentHeader, Is.EqualTo(packet.Header));
        }
コード例 #9
0
        public void PacketListTest()
        {
            bool visualStateUpdated = false;

            _model.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
            {
                visualStateUpdated = true;
            };

            Assert.That(_model.Packets, Is.EqualTo(new BindingList <PacketViewModel>()));

            PacketViewModel packet             = new PacketViewModel(GetPacketExample());
            BindingList <PacketViewModel> list = new BindingList <PacketViewModel>()
            {
                packet
            };

            _model.Packets = list;
            Assert.That(_model.Packets, Is.EqualTo(list));

            Assert.True(visualStateUpdated);
        }
コード例 #10
0
        public void OpenDetailsInNewTab(PacketViewModel packet)
        {
            Contract.Requires <ArgumentNullException>(packet != null);

            throw new NotImplementedException();
        }
コード例 #11
0
        public void OpenDetails(PacketViewModel packet)
        {
            Contract.Requires <ArgumentNullException>(packet != null);

            this.openPacketDetails.OpenDetailsInNewTab(packet);
        }
コード例 #12
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            try
            {
                Packet packet = ViewModel.Packet;

                packet.Words.Clear();
                foreach (string line in wordsTextBox.Lines)
                {
                    packet.Words.Add(line);
                }
                InvokePacketCreated(packet);
            }
            catch (Exception ex)
            {
                InvokeBuildError(ex);
            }
            finally
            {
                ViewModel = new PacketViewModel(new Packet());
                packetViewModelBindingSource.DataSource = ViewModel;
                packetViewModelBindingSource.ResetBindings(false);
            }
        }
コード例 #13
0
 public PacketBuilderControl()
 {
     InitializeComponent();
     ViewModel = new PacketViewModel(new Packet());
     packetViewModelBindingSource.DataSource = ViewModel;
 }
コード例 #14
0
        private bool AcceptFilterData(PacketViewModel packet, IReadOnlyFilterData filterData)
        {
            if (filterData.ForceIncludePacketNumbers != null)
            {
                if (filterData.ForceIncludePacketNumbers.Contains(packet.Id))
                {
                    return(true);
                }
            }

            if (filterData.MinPacketNumber.HasValue && packet.Id < filterData.MinPacketNumber.Value)
            {
                return(false);
            }
            if (filterData.MaxPacketNumber.HasValue && packet.Id > filterData.MaxPacketNumber.Value)
            {
                return(false);
            }

            if (filterData.IncludedEntries != null)
            {
                if (!filterData.IncludedEntries.Contains(packet.Entry))
                {
                    return(false);
                }
            }
            else if (filterData.ExcludedEntries != null)
            {
                if (filterData.ExcludedEntries.Contains(packet.Entry))
                {
                    return(false);
                }
            }

            if (filterData.IncludedOpcodes != null)
            {
                if (!filterData.IncludedOpcodes.Contains(packet.Opcode))
                {
                    return(false);
                }
            }
            else if (filterData.ExcludedOpcodes != null)
            {
                if (filterData.ExcludedOpcodes.Contains(packet.Opcode))
                {
                    return(false);
                }
            }

            if (filterData.IncludedOpcodesWildcards != null)
            {
                bool any = false;
                foreach (var prefix in filterData.IncludedOpcodesWildcards)
                {
                    if (packet.Opcode.StartsWith(prefix))
                    {
                        any = true;
                        break;
                    }
                }

                if (!any)
                {
                    return(false);
                }
            }
            if (filterData.ExcludedOpcodesWildcards != null)
            {
                foreach (var prefix in filterData.ExcludedOpcodesWildcards)
                {
                    if (packet.Opcode.StartsWith(prefix))
                    {
                        return(false);
                    }
                }
            }

            if (filterData.IncludedGuids != null)
            {
                foreach (var guid in filterData.IncludedGuids)
                {
                    if ((packet.MainActor?.Equals(guid) ?? false) || packet.Text.Contains(guid.ToHexString()))
                    {
                        return(true);
                    }
                }

                return(false);
            }
            else if (filterData.ExcludedGuids != null)
            {
                foreach (var guid in filterData.ExcludedGuids)
                {
                    if (packet.Text.Contains(guid.ToHexString()))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(true);
        }
コード例 #15
0
 public void OpenDetailsInNewTab(PacketViewModel packet)
 {
     var packetDetailsDocumentItem = this.packetDetailsDocumentItemVMFactory.Create();
     packetDetailsDocumentItem.PacketDetails.Packet = packet;
     this.bus.Publish(new ItemOpenedEvent(packetDetailsDocumentItem));
 }