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 SetupSniffer() { if (!_sniffer.AvailiableDevicesNames.Contains(_cliFlags.CaptureDevice)) { CliPrinter.Error($"No such device: {_cliFlags.CaptureDevice}"); Environment.Exit(0); } _sniffer.SelectedDeviceName = _cliFlags.CaptureDevice; if (_cliFlags.PromisciousMode) { _sniffer.PromisciousMode = true; } if (_cliFlags.CaptrueFilter != null) { if (!Sniffer.CheckCaptureFilter(_cliFlags.CaptrueFilter)) { CliPrinter.Error($"The capture filter: {_cliFlags.CaptrueFilter} is not a valid filter - filters must be in a bpf format"); Environment.Exit(0); } _sniffer.Filter = _cliFlags.CaptrueFilter; } }
private void ExportResults() { if (_cliFlags.OutputDir != null) { if (_connections.Any()) { var filePath = CommonUi.Exporting.ExportNetworkMap(_cliFlags.OutputDir, _connections); CliPrinter.Info($"Successfully exported network map to json file: {filePath}"); } if (_hashes.Any()) { Utilities.ExportHashes(_cliFlags.OutputDir, _hashes); CliPrinter.Info($"Successfully exported hashes"); } if (_files.Any()) { var dirPath = CommonUi.Exporting.ExportFiles(_cliFlags.OutputDir, _extractedFiles); CliPrinter.Info($"Successfully exported extracted files to: {dirPath}"); } if (_dnsMappings.Any()) { var dnsFilePath = CommonUi.Exporting.ExportDnsMappings(_cliFlags.OutputDir, _dnsMappings); CliPrinter.Info($"Successfully exported DNS mappings to file: {dnsFilePath}"); } if (_voipCalls.Any()) { var dirPath = CommonUi.Exporting.ExportVoipCalls(_cliFlags.OutputDir, _voipCalls); CliPrinter.Info($"Successfully exported voip calss extracted to: {dirPath}"); } } CliPrinter.Info("Bruteshark finished processing"); }
private void ExportResults() { if (_cliFlags.OutputDir != null) { if (_networkContext.Connections.Any()) { var networkMapFilePath = CommonUi.Exporting.ExportNetworkMap(_cliFlags.OutputDir, _networkContext.Connections); CliPrinter.Info($"Successfully exported network map to json file: {networkMapFilePath}"); var nodesDataFilePath = CommonUi.Exporting.ExportNetworkNodesData(_cliFlags.OutputDir, _networkContext.GetAllNodes()); CliPrinter.Info($"Successfully exported network nodes data to json file: {nodesDataFilePath}"); } if (_networkContext.Hashes.Any()) { Utilities.ExportHashes(_cliFlags.OutputDir, _networkContext.Hashes); CliPrinter.Info($"Successfully exported hashes"); } if (_files.Any()) { var dirPath = CommonUi.Exporting.ExportFiles(_cliFlags.OutputDir, _extractedFiles); CliPrinter.Info($"Successfully exported extracted files to: {dirPath}"); } if (_networkContext.DnsMappings.Any()) { var dnsFilePath = CommonUi.Exporting.ExportDnsMappings(_cliFlags.OutputDir, _networkContext.DnsMappings); CliPrinter.Info($"Successfully exported DNS mappings to file: {dnsFilePath}"); } if (_voipCalls.Any()) { var dirPath = CommonUi.Exporting.ExportVoipCalls(_cliFlags.OutputDir, _voipCalls); CliPrinter.Info($"Successfully exported Voip calls extracted to: {dirPath}"); } } CliPrinter.Info("BruteShark finished processing"); }
private void AddFile(string filePath) { if (File.Exists(filePath)) { _files.Add(filePath); } else { CliPrinter.Error($"File does not exist - {filePath}"); } }
private void PrintFileStatusUpdate(object sender, FileProcessingStatusChangedEventArgs e) { if (e.Status == FileProcessingStatus.Started) { CliPrinter.Info($"Start processing file : {Path.GetFileName(e.FilePath)}"); } else if (e.Status == FileProcessingStatus.Finished) { CliPrinter.Info($"Finished processing file : {Path.GetFileName(e.FilePath)}"); } else if (e.Status == FileProcessingStatus.Faild) { CliPrinter.Error($"Failed to process file : {Path.GetFileName(e.FilePath)}"); } }
private void PrintUpdatedItem(object item, string propertyUpdatedName) { CliPrinter.WriteLine(ConsoleColor.Blue, $"Updated {propertyUpdatedName} for: {item}"); }
private void PrintDetectedItem(object item) { CliPrinter.WriteLine(ConsoleColor.Blue, $"Found: {item}"); }
public static void Error(Exception exception) => CliPrinter.Error(exception.Message);
public static void Error(string text) => CliPrinter.WriteLine(ConsoleColor.Red, $"ERROR: {text}");
public static void Info(string text) => CliPrinter.WriteLine(ConsoleColor.Green, $"[+] {text}");