예제 #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);
            }
        }
        /// <summary>
        /// Read the IENetP Wireshark fields file.
        /// If the file exists, read the file and check the version against the currently installed version of Tshark.
        /// If the file doesn't exist or the version disagree, build a new version of the Wireshark fields file.
        /// </summary>
        /// <returns>A <c>bool</c> indicating whether the Wireshark fields file was read correctly and/or a new version was built correctly</returns>
        private bool ReadWiresharkFieldsFile()
        {
            _status_message = "Reading Wireshark Fields File";

            FileInfo fields_file = new FileInfo(_application_directory + "\\" + Constants.IENetPFileHeader + Constants.WiresharkFieldsFileName + Constants.XmlFileExtension);
            if (fields_file.Exists)
            {
                // Deserialize the fields file
                XmlSerializer deserializer = new XmlSerializer(typeof(WiresharkFields));
                TextReader reader = new StreamReader(fields_file.FullName);
                _current_wireshark_fields = (WiresharkFields)deserializer.Deserialize(reader);
                reader.Close();

                if (_current_wireshark_fields.WiresharkVersion == _tshark_app.VersionString)
                    _build_new_fields_file = false;
            }

            return true;
        }
예제 #3
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());
            }
        }