Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExecutedBuildWiresharkFields(object sender, ExecutedRoutedEventArgs e)
        {
            BuildWiresharkFieldsWindow build_fields_dlg = new BuildWiresharkFieldsWindow();
            build_fields_dlg.TemporaryDirectory = _temporary_directory;
            build_fields_dlg.ApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
            build_fields_dlg.TSharkApp = _tshark;

            bool? result = build_fields_dlg.ShowDialog();
            if (result == true)
            {
                _wireshark_fields = build_fields_dlg.CurrentWiresharkFields;
            }
            else
            {
                string error_message = "An error occured while trying to build the Wireshark fields file. ";
                error_message += "Please refer to the error below for more information.\n\n";
                error_message += "BUILD WIRESHARK FIELDS: " + build_fields_dlg.ErrorMessage;
                System.Windows.MessageBox.Show(error_message, "ERROR: Building Wireshark Fields", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
        }
Example #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string[] args = Environment.GetCommandLineArgs();
            if (args.Length == 5 && args.Contains("/pcap") && args.Contains("/ip"))
            {
                _command_line_called = true;
            }
            this.Cursor = System.Windows.Input.Cursors.AppStarting;

            ClearResults();
            BuildDefaultWiresharkFilter();
            BuildWiresharkFieldTypes();
            _activate_save = false;
            _temporary_directory = Environment.GetEnvironmentVariable(Constants.TemporaryFileEnvironmentVariable);

            System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
            host.Child = _chart_main;
            this.gridChart.Children.Add(host);

            _chart_main.BackGradientStyle = GradientStyle.TopBottom;
            _chart_main.BackColor = System.Drawing.Color.AliceBlue;
            _chart_main.BackSecondaryColor = System.Drawing.Color.Azure;
            BuildChartBars();

            InitializeIENetPWindow init_dlg = new InitializeIENetPWindow();
            init_dlg.TemporaryDirectory = _temporary_directory;
            init_dlg.ApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
            init_dlg.CapinfosApp = _capinfos;
            init_dlg.TSharkApp = _tshark;

            bool? result = init_dlg.ShowDialog();
            if (result == true)
            {
                if (init_dlg.BuildNewFieldsFile && (_command_line_called || (
                    System.Windows.MessageBoxResult.Yes == System.Windows.MessageBox.Show("A different version of Wireshark has been detected since the last time the Wireshark Fields File was built.\nWould you like to rebuild the Fields File now?\n\nYou can rebuild it later by choosing the option in the Tools menu.", "Rebuild Wireshark Fields File?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes))))
                    {
                        BuildWiresharkFieldsWindow build_fields_dlg = new BuildWiresharkFieldsWindow();
                        build_fields_dlg.TemporaryDirectory = _temporary_directory;
                        build_fields_dlg.ApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
                        build_fields_dlg.TSharkApp = _tshark;

                        result = build_fields_dlg.ShowDialog();
                        if (result == true)
                        {
                            _wireshark_fields = build_fields_dlg.CurrentWiresharkFields;
                        }
                        else
                        {
                            string error_message = "An error occured while trying to build the Wireshark fields file. ";
                            error_message += "Please refer to the error below for more information.\n\n";
                            error_message += "BUILD WIRESHARK FIELDS: " + build_fields_dlg.ErrorMessage;
                            System.Windows.MessageBox.Show(error_message, "ERROR: Building Wireshark Fields", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                        }
                }
                else
                {
                    _wireshark_fields = init_dlg.CurrentWiresharkFields;
                }
            }
            else
            {
                string error_message = "An error occured while trying to initialize the application. ";
                error_message += "The application will quit.  Please refer to the error below for more information.\n\n";
                error_message += "INITALIZATION: " + init_dlg.ErrorMessage;
                System.Windows.MessageBox.Show(error_message, "ERROR: Initializing Application", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                this.Close();
            }

            this.Cursor = System.Windows.Input.Cursors.Arrow;

            /* try to automatic start analyse if command line parameters are available */
            if (_command_line_called)
            {
                for (int index = 0; index < args.Length; index++)
                {
                    if ("/ip" == args[index]) textBoxIpAddress.Text = args[index + 1];
                    if ("/pcap" == args[index]) textBoxCaptureFile.Text = args[index + 1];
                }
                buttonAnalyze_Click(this, new RoutedEventArgs());
            }
        }