Example #1
0
        private void AddProcByName(string proc)
        {
            if (String.IsNullOrEmpty(proc) || !proc.EndsWith(".exe"))
            {
                MessageBox.Show("Please enter a valid process name (*.exe)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (CheckListboxContainsItem(lvProtProc, proc))
            {
                MessageBox.Show("This process already exists - please remove first or edit existing entry.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string newList = proc;

            foreach (ListViewItem lvi in lvProtProc.Items)
            {
                newList += "|" + lvi.Text;
            }

            newList = newList.Trim('|');

            XmlConfig.SetConfigString("configuration/protectedProcessList/property/processList", newList);
            lvProtProc.Items.Insert(0, proc);
        }
Example #2
0
        private void btnRemoveProc_Click(object sender, EventArgs e)
        {
            if (!LoadConfigOrShowError("config.xml"))
            {
                return;
            }

            string newList = "";

            if (lvProtProc.SelectedItems.Count == 0)
            {
                return;
            }

            for (int i = 0; i < lvProtProc.Items.Count; i++)
            {
                if (lvProtProc.SelectedItems[0].Index != i)
                {
                    newList += lvProtProc.Items[i].Text;

                    if (i + 1 < lvProtProc.Items.Count)
                    {
                        newList += "|";
                    }
                }
            }

            newList = newList.Trim('|');

            string procName = (string)lvProtProc.SelectedItems[0].Text;

            lvProtProc.Items.RemoveAt(lvProtProc.SelectedItems[0].Index);
            XmlConfig.SetConfigString("configuration/protectedProcessList/property/processList", newList);

            if (procName != null)
            {
                string configXml = procName.Replace(".exe", "_config.xml");

                if (File.Exists(EventManager.InstallPath + configXml))
                {
                    DialogResult dlgResult = MessageBox.Show(
                        "Delete custom configuration for \"" + procName + "\"?",
                        "Delete Configuration",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question);

                    if (dlgResult == System.Windows.Forms.DialogResult.Yes)
                    {
                        File.Delete(EventManager.InstallPath + configXml);
                    }
                }
            }
        }
Example #3
0
        private void cbEnableDiD_CheckedChanged(object sender, EventArgs e)
        {
            if (undergoingUIUpdate)
            {
                return;
            }

            XmlConfig.SetConfigString("configuration/defenseInDepth/property/enabled", cbEnableDiD.Checked ? "true" : "false");

            if (ExpertOptions.RefEnableDiDCore != null)
            {
                ExpertOptions.RefEnableDiDCore.Checked = cbEnableDiD.Checked;
            }
        }
Example #4
0
        private void cbEnableCF_CheckedChanged(object sender, EventArgs e)
        {
            if (undergoingUIUpdate)
            {
                return;
            }

            XmlConfig.SetConfigString("configuration/browserProtection/property/enabled", cbEnableCF.Checked ? "true" : "false");

            if (ExpertOptions.RefEnableBpCore != null)
            {
                ExpertOptions.RefEnableBpCore.Checked = cbEnableCF.Checked;
            }
        }
Example #5
0
        public static void SetProtectionLevelInConfig(EProtectionLevel protLevel)
        {
            if (XmlConfig.Path == null)
            {
                throw new Exception("XmlConfig needs to have been initialised before calling");
            }

            Dictionary <string, string> settings = protLevelPresets[(int)protLevel];

            foreach (KeyValuePair <string, string> kvp in settings)
            {
                XmlConfig.SetConfigString(kvp.Key, kvp.Value);
            }
        }
Example #6
0
        private void cbPromptUserExe_CheckedChanged(object sender, EventArgs e)
        {
            string xmlPathLast = new FileInfo(XmlConfig.Path).Name;

            if (string.IsNullOrEmpty(xmlPathLast))
            {
                return;
            }

            if (!LoadConfigOrShowError("config.xml"))
            {
                return;
            }

            XmlConfig.SetConfigString("configuration/apiMonitor/property/promptUserExeBlocked", cbPromptUserExe.Checked ? "true" : "false");

            if (!LoadConfigOrShowError(xmlPathLast))
            {
                return;
            }
        }
Example #7
0
        private void cbPromptOnDotNet_CheckedChanged(object sender, EventArgs e)
        {
            string xmlPathLast = new FileInfo(XmlConfig.Path).Name;

            if (string.IsNullOrEmpty(xmlPathLast))
            {
                return;
            }

            if (!LoadConfigOrShowError("config.xml"))
            {
                return;
            }

            XmlConfig.SetConfigString("configuration/apiMonitor/property/promptRelaxDotnet", cbPromptOnDotNet.Checked ? "true" : "false");
            MainUI.MinimizeToTray = cbMinimizeToTray.Checked;

            if (!LoadConfigOrShowError(xmlPathLast))
            {
                return;
            }
        }
Example #8
0
        private void cbMinimizeToTray_CheckedChanged(object sender, EventArgs e)
        {
            string xmlPathLast = new FileInfo(XmlConfig.Path).Name;

            if (string.IsNullOrEmpty(xmlPathLast))
            {
                return;
            }

            if (!LoadConfigOrShowError("config.xml"))
            {
                return;
            }

            XmlConfig.SetConfigString("configuration/defenseInDepth/property/minimizeToTray", cbMinimizeToTray.Checked ? "true" : "false");
            MainUI.MinimizeToTray = cbMinimizeToTray.Checked;

            if (!LoadConfigOrShowError(xmlPathLast))
            {
                return;
            }
        }
Example #9
0
        private bool SavePendingSettings()
        {
            bool allSaved = true;

            foreach (KeyValuePair <string, string> kvp in pendingSettings)
            {
                if (XmlConfig.GetConfigString(kvp.Key) == null)
                {
                    string keyAlternate = null;

                    if (kvp.Key.Contains("/Enabled:"))
                    {
                        // the entry may exist in the xml config as Disabled ...
                        keyAlternate = kvp.Key.Replace("/Enabled:", "/Disabled:");
                    }
                    else if (kvp.Key.Contains("/Disabled:"))
                    {
                        // as may the opposite occur ...
                        keyAlternate = kvp.Key.Replace("/Disabled:", "/Enabled:");
                    }

                    NaiveConfigWriter writer = new NaiveConfigWriter(XmlConfig.Path);

                    if (keyAlternate != null)
                    {
                        if (XmlConfig.GetConfigString(keyAlternate) != null)
                        {
                            // remove keyAlternate and continue
                            writer.RemoveXmlPropertyWithPath(keyAlternate);
                        }
                    }

                    // this config entry doesn't exist (i.e. a new imported filter)
                    // add new entry to config file before proceeding.

                    int idx = kvp.Key.LastIndexOf('/');

                    // this code should be tested later
                    string xmlPropertyPath = kvp.Key.Substring(0, idx);
                    string xmlPropertyName = kvp.Key.Substring(idx + 1);

                    writer.AddXmlPropertyAtPath(xmlPropertyPath, xmlPropertyName, kvp.Value);

                    // then update config
                    if (!XmlConfig.RefreshConfig())
                    {
                        ShowConfigLoadError();
                        return(false);
                    }
                }
                else
                {
                    if (!XmlConfig.SetConfigString(kvp.Key, kvp.Value))
                    {
                        allSaved = false;
                    }
                }
            }

            pendingSettings.Clear();

            return(allSaved);
        }
Example #10
0
        private bool AddFilterModule(string filterFile)
        {
            // ensure DLL file
            //
            // pinvoke: BOOL filter!QueryFilters(
            //     char ***pppszConnectExports, int *pnConnectExports,
            //     char ***pppszRequestExports, int *pnRequestExports,
            //     char ***pppszResponseExports, int *pnResponseExports
            // );
            //
            // if(BOOL result == true) add exports to XML config, update UI (and update options dialog UI)
            //
            // return BOOL result

            string[] connectFilters = null, requestFilters = null, responseFilters = null;

            bool result = FilterNativeMethods.QueryFilters(filterFile,
                                                           out connectFilters, out requestFilters, out responseFilters
                                                           );

            if (!result)
            {
                return(false);
            }

            // we can add the filters

            NaiveConfigWriter writer = new NaiveConfigWriter(XmlConfig.Path);

            if (connectFilters != null)
            {
                foreach (string filter in connectFilters)
                {
                    if (XmlConfig.GetConfigString("configuration/connectFilters/property/Enabled:" + filter) == null)
                    {
                        writer.AddXmlPropertyAtPath("configuration/connectFilters/property", "Enabled:" + filter, filterFile);
                    }
                    else
                    {
                        XmlConfig.SetConfigString("configuration/connectFilters/property/Enabled:" + filter, filterFile);
                    }

                    if (XmlConfig.GetConfigString("configuration/connectFilters/property/Disabled:" + filter) != null)
                    {
                        writer.RemoveXmlPropertyWithPath("configuration/connectFilters/property/Disabled:" + filter);
                    }
                }
            }

            if (requestFilters != null)
            {
                foreach (string filter in requestFilters)
                {
                    if (XmlConfig.GetConfigString("configuration/requestFilters/property/Enabled:" + filter) == null)
                    {
                        writer.AddXmlPropertyAtPath("configuration/requestFilters/property", "Enabled:" + filter, filterFile);
                    }
                    else
                    {
                        XmlConfig.SetConfigString("configuration/requestFilters/property/Enabled:" + filter, filterFile);
                    }

                    if (XmlConfig.GetConfigString("configuration/requestFilters/property/Disabled:" + filter) != null)
                    {
                        writer.RemoveXmlPropertyWithPath("configuration/requestFilters/property/Disabled:" + filter);
                    }
                }
            }

            if (responseFilters != null)
            {
                foreach (string filter in responseFilters)
                {
                    if (XmlConfig.GetConfigString("configuration/responseFilters/property/Enabled:" + filter) == null)
                    {
                        writer.AddXmlPropertyAtPath("configuration/responseFilters/property", "Enabled:" + filter, filterFile);
                    }
                    else
                    {
                        XmlConfig.SetConfigString("configuration/responseFilters/property/Enabled:" + filter, filterFile);
                    }

                    if (XmlConfig.GetConfigString("configuration/responseFilters/property/Disabled:" + filter) != null)
                    {
                        writer.RemoveXmlPropertyWithPath("configuration/responseFilters/property/Disabled:" + filter);
                    }
                }
            }

            return(true);
        }