public void Run() { try { SetupRun(); if (_cliFlags.CaptureDevice != null) { SetupSniffer(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(_sniffer.PromisciousMode ? $"[+] Started analyzing packets from {_cliFlags.CaptureDevice} device (Promiscious mode) - Press any Ctrl + C to stop" : $"[+] Started analyzing packets from {_cliFlags.CaptureDevice} device- Press Ctrl + C to stop"); Console.ForegroundColor = ConsoleColor.White; _sniffer.StartSniffing(new System.Threading.CancellationToken()); } else { _processor.ProcessPcaps(_files); } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public void Run() { try { SetupRun(); if (_cliFlags.CaptureDevice != null) { SetupSniffer(); CliPrinter.Info(_sniffer.PromisciousMode ? $"Started analyzing packets from {_cliFlags.CaptureDevice} device (Promiscious mode) - Press Ctrl + C to stop" : $"Started analyzing packets from {_cliFlags.CaptureDevice} device - Press Ctrl + C to stop"); _sniffer.StartSniffing(new System.Threading.CancellationToken()); } else { CliPrinter.Info($"Start analyzing {_files.Count} files"); _processor.ProcessPcaps(_files); } } catch (Exception ex) { CliPrinter.Error(ex); } }
private void RunButton_Click(object sender, EventArgs e) { // Reset all files status. foreach (ListViewItem item in this.filesListView.Items) { item.ForeColor = Color.Black; item.SubItems[2].Text = "Wait"; } new Thread(() => _processor.ProcessPcaps(this._files)).Start(); }
public void Run() { try { SetupRun(); Console.WriteLine($"[+] Started analyzing {_files.Count} files"); _processor.ProcessPcaps(_files); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public void PcapProcessor_ReadTcpPacketsMultipleFiles_ReadSuccess() { // Arrange. var recievedPackets = new List <PcapProcessor.TcpPacket>(); var processor = new PcapProcessor.Processor(); processor.TcpPacketArived += (object sender, TcpPacketArivedEventArgs e) => recievedPackets.Add(e.Packet); // Act. processor.ProcessPcaps(new List <string>() { this.HttpSmallFilePath, this.TcpFivePacketsFilePath }); // Assert. Assert.AreEqual(46, recievedPackets.Count); }
private void StartAnalyzing() { if (liveCapture) { try { Console.WriteLine(_sniffer.PromisciousMode ? $"[+] Started analyzing packets from {_sniffer.SelectedDeviceName} device (Promiscious mode) - Press Ctrl + C to stop" : $"[+] Started analyzing packets from {_sniffer.SelectedDeviceName} device- Press Ctrl + C to stop"); _sniffer.StartSniffing(new System.Threading.CancellationToken()); Console.SetCursorPosition(0, Console.CursorTop + 6); } catch (SharpPcap.PcapException e) { Console.WriteLine($"Capture Filter: {_sniffer.Filter} is invalid"); } } else { _processor.ProcessPcaps(this._files, liveCaptureDevice: _networkDevice); Console.SetCursorPosition(0, Console.CursorTop + 5); } }
private void RunButton_Click(object sender, EventArgs e) { new Thread(() => _processor.ProcessPcaps(this._files)).Start(); }