/// <summary>
        /// Build the Network event Signature decisiontree from the XML signature  string
        /// </summary>
        /// <param name="signature"></param>
        /// <returns></returns>
        private bool BuildDecisionTree(string signature)
        {
            try
            {
                _tree = TestDecisionTree.XmlDeserialize(signature);

                return(_tree != null);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public FDSApplicationContext()
            : base()
        {
            try
            {
                dao = new MySqlDao();
                Flow2.SetLabelTable(dao.GetFlowLabels());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                MessageBox.Show("Please check DB connection, Exitting");
                Application.Exit();
            }

            //reading the default signature file
            string xmlSig = default(string);

            try
            {
                System.Console.WriteLine("the path is:" + Properties.Settings.Default.SignatureFile);
                using (StreamReader sr = new StreamReader(Properties.Settings.Default.SignatureFile))
                {
                    xmlSig = sr.ReadToEnd();
                }
                System.Diagnostics.Debug.WriteLine("Deserializing Signature File: " + Properties.Settings.Default.SignatureFile);
                _tree = TestDecisionTree.XmlDeserialize(xmlSig);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Problem with Signature File");
                //terminate the thread, just return
                return;
            }

            _openTrainingSetDlg = new OpenFileDialog();
            _openTrainingSetDlg.CheckFileExists = true;
            _openTrainingSetDlg.CheckPathExists = true;

            _openOfflineDetectionDlg = new OpenFileDialog();
            _openOfflineDetectionDlg.CheckFileExists = true;
            _openOfflineDetectionDlg.CheckPathExists = true;



            _trainingPercentage = Properties.Settings.Default.TrainingPercentage;

            _dataServicePort = Properties.Settings.Default.DataSvcPort;

            _malFlowDetector = new MalFlowDetectMon();

            ///TODO: We need to make this timewindow configrable
            _malFlowDetector.TimeWindow = new TimeSpan(0, 0, Properties.Settings.Default.TimeWindow);
            //_malFlowDetector.TimeWindow = new TimeSpan(0, 0, 1);
            _malFlowDetector.DetectionEvent += new NetworkDetectionEventHandler(ProcessNetworkEvent);
            _malFlowDetector.ErrorEvent     += new PMErrorEventHandler(DisplayErrorEvent);

            _malFlowDetector.Start();

            _dbThread = CreateDatabaseThread();
            _dbThread.Start();

            _components             = new System.ComponentModel.Container();
            _contextMenu            = CreateContextMenu();
            _notifyIcon             = CreateSystrayIcon("Flow Detector Server", true);
            _notifyIcon.ContextMenu = _contextMenu;

            this.ThreadExit += new EventHandler(this.SystrayIcon_ApplicationExit);

            this.ThreadExit += new EventHandler(this.Application_Exit);
        }