Exemplo n.º 1
0
        private void toolStripButton_ModifyFolder_Click(object sender, EventArgs e)
        {
            if (listView_LockFolders.SelectedItems.Count != 1)
            {
                MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                MessageBox.Show("Please select one item to delete.", "Delete Folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            System.Windows.Forms.ListViewItem item = listView_LockFolders.SelectedItems[0];
            FolderLockerSettigs folderLocker       = new FolderLockerSettigs((FilterRule)item.Tag);

            if (folderLocker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FilterRule filterRule = folderLocker.filterRule;

                GlobalConfig.RemoveFilterRule(((FilterRule)item.Tag).IncludeFileFilterMask);
                GlobalConfig.AddFilterRule(filterRule);
                GlobalConfig.SaveConfigSetting();

                InitFolderLockerListView();
            }


            InitFolderLockerListView();
        }
Exemplo n.º 2
0
        private bool AddEncyrptFolder(string folderName)
        {
            if (GlobalConfig.FilterRules.Count == 0)
            {
                //delete the predefined items for users.
                listView_Folders.Items.Clear();
            }


            string includeFilterMask = folderName + "\\*";

            if (!GlobalConfig.IsFilterRuleExist(includeFilterMask))
            {
                FilterRule filterRule = new FilterRule();
                filterRule.IncludeFileFilterMask = includeFilterMask;
                GlobalConfig.AddFilterRule(filterRule);

                ListViewItem item = new ListViewItem(folderName);
                item.ImageIndex = 0;
                listView_Folders.Items.Add(item);

                listView_Folders.EnsureVisible(listView_Folders.Items.Count - 1);

                ApplySettingsToFilterDriver();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        private void button_SaveSandBox_Click(object sender, EventArgs e)
        {
            if (GetSandboxSetting())
            {
                GlobalConfig.AddFilterRule(selectedFilterRule);
                GlobalConfig.AddProcessFilterRule(selectedProcessFilterRule);
                GlobalConfig.AddRegistryFilterRule(selectedRegistryFilterRule);
                GlobalConfig.SaveConfigSetting();
            }

            InitListView();
        }
Exemplo n.º 4
0
        private void toolStripButton_AddFolder_Click(object sender, EventArgs e)
        {
            FolderLockerSettigs folderLocker = new FolderLockerSettigs(null);

            if (folderLocker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FilterRule filterRule = folderLocker.filterRule;

                GlobalConfig.AddFilterRule(filterRule);

                GlobalConfig.SaveConfigSetting();

                InitFolderLockerListView();
            }
        }
Exemplo n.º 5
0
        static public void ApplySettingsToFilterDriver()
        {
            FilterRule filterRuleShareFolder = new FilterRule();

            filterRuleShareFolder.Id = GlobalConfig.GetFilterRuleId();
            filterRuleShareFolder.IncludeFileFilterMask = GlobalConfig.ShareFolder + "\\*";
            filterRuleShareFolder.AccessFlag           |= (uint)FilterAPI.AccessFlag.ENABLE_FILE_ENCRYPTION_RULE | FilterAPI.ALLOW_MAX_RIGHT_ACCESS;
            filterRuleShareFolder.AccessFlag           &= (uint)(~FilterAPI.AccessFlag.ALLOW_ENCRYPT_NEW_FILE);// this folder won't encrypt the new file.
            filterRuleShareFolder.EncryptMethod         = (int)FilterAPI.EncryptionMethod.ENCRYPT_FILE_WITH_SAME_KEY_AND_UNIQUE_IV;
            filterRuleShareFolder.EncryptionPassPhrase  = GlobalConfig.MasterPassword;

            GlobalConfig.AddFilterRule(filterRuleShareFolder);

            //send the filter rule settings to the filter driver here.
            GlobalConfig.SaveConfigSetting();
        }
Exemplo n.º 6
0
        private bool AddEncyrptFolder(string folderName)
        {
            if (GlobalConfig.FilterRules.Count == 0)
            {
                //delete the predefined items for users.
                listView_Folders.Items.Clear();
            }

            uint   accessFlags       = FilterAPI.ALLOW_MAX_RIGHT_ACCESS | (uint)FilterAPI.AccessFlag.FILE_ENCRYPTION_RULE;
            string includeFilterMask = folderName + "\\*";

            if (!GlobalConfig.IsFilterRuleExist(includeFilterMask))
            {
                FilterRule filterRule = new FilterRule();
                filterRule.IncludeFileFilterMask  = includeFilterMask;
                filterRule.ExcludeFileFilterMasks = "";
                filterRule.EncryptionPassPhrase   = GlobalConfig.MasterPassword;
                filterRule.IncludeProcessNames    = "";
                filterRule.ExcludeProcessNames    = "";
                filterRule.IncludeProcessIds      = "";
                filterRule.ExcludeProcessIds      = "";
                filterRule.HiddenFileFilterMasks  = "";
                filterRule.AccessFlag             = accessFlags;
                filterRule.EventType = 0;
                GlobalConfig.AddFilterRule(filterRule);

                GlobalConfig.SaveConfigSetting();

                ListViewItem item = new ListViewItem(folderName);
                item.ImageIndex = 0;
                listView_Folders.Items.Add(item);

                listView_Folders.EnsureVisible(listView_Folders.Items.Count - 1);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        private void button_ConfigProcessRights_Click(object sender, EventArgs e)
        {
            if (textBox_SandboxFolder.Text.Trim().Length == 0)
            {
                MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                MessageBox.Show("Sandbox folder can't be empty.", "config sendbox", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (selectedFilterRule.IncludeFileFilterMask != textBox_SandboxFolder.Text)
            {
                GetSandboxSetting();
            }

            Form_ProcessRights processRights = new Form_ProcessRights(ref selectedFilterRule);

            if (processRights.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                selectedFilterRule = processRights.currentFilterRule;
                GlobalConfig.AddFilterRule(selectedFilterRule);
                InitListView();
            }
        }
Exemplo n.º 8
0
        static public void ApplySettingsToFilterDriver()
        {
            GlobalConfig.RemoveAllFilterRules();
            string[] whiteList = null;
            string[] blacklist = null;

            FilterRule filterRuleShareFolder = new FilterRule();

            filterRuleShareFolder.IncludeFileFilterMask = GlobalConfig.ShareFolder + "\\*";
            filterRuleShareFolder.AccessFlag           |= (uint)FilterAPI.AccessFlag.ENABLE_FILE_ENCRYPTION_RULE | FilterAPI.ALLOW_MAX_RIGHT_ACCESS;
            filterRuleShareFolder.AccessFlag           &= (uint)(~FilterAPI.AccessFlag.ALLOW_ENCRYPT_NEW_FILE);     // this folder won't encrypt the new file.
            filterRuleShareFolder.AccessFlag           &= (uint)(~FilterAPI.AccessFlag.ALLOW_READ_ENCRYPTED_FILES); // all process can't read the encyrpted file except the authorized processes.
            filterRuleShareFolder.EncryptMethod         = (int)FilterAPI.EncryptionMethod.ENCRYPT_FILE_WITH_SAME_KEY_AND_UNIQUE_IV;
            filterRuleShareFolder.EncryptionPassPhrase  = GlobalConfig.MasterPassword;

            //for whitelist process, it has maximum acess rights.
            if (GlobalConfig.ProtectFolderWhiteList == "*")
            {
                //allow all processes to read the encrypted file except the black list processes.
                filterRuleShareFolder.AccessFlag |= (uint)(FilterAPI.AccessFlag.ALLOW_READ_ENCRYPTED_FILES);
            }
            else
            {
                //for whitelist process, it has maximum acess rights.
                whiteList = GlobalConfig.ShareFolderWhiteList.Split(new char[] { ';' });
                if (whiteList.Length > 0)
                {
                    foreach (string authorizedUser in whiteList)
                    {
                        if (authorizedUser.Trim().Length > 0)
                        {
                            //not allow to encrypt the new file
                            uint accessFlag = filterRuleShareFolder.AccessFlag | (uint)(FilterAPI.AccessFlag.ALLOW_READ_ENCRYPTED_FILES);
                            filterRuleShareFolder.ProcessRights += ";" + authorizedUser + "!" + accessFlag.ToString();
                        }
                    }
                }
            }

            //for blacklist process, it has maximum acess rights.
            blacklist = GlobalConfig.ShareFolderBlackList.Split(new char[] { ';' });
            if (blacklist.Length > 0)
            {
                foreach (string unAuthorizedUser in blacklist)
                {
                    if (unAuthorizedUser.Trim().Length > 0)
                    {
                        //can't read the encrypted files, not allow to encrypt the new file
                        uint accessFlag = filterRuleShareFolder.AccessFlag;
                        filterRuleShareFolder.ProcessRights += ";" + unAuthorizedUser + "!" + accessFlag.ToString();
                    }
                }
            }


            FilterRule filterRuleProtectFolder = new FilterRule();

            filterRuleProtectFolder.IncludeFileFilterMask = GlobalConfig.ProtectFolder + "\\*";
            filterRuleProtectFolder.AccessFlag           |= (uint)FilterAPI.AccessFlag.ENABLE_FILE_ENCRYPTION_RULE | FilterAPI.ALLOW_MAX_RIGHT_ACCESS;
            filterRuleProtectFolder.AccessFlag           &= (uint)(~FilterAPI.AccessFlag.ALLOW_READ_ENCRYPTED_FILES);// all process can't read the encyrpted file except the authorized processes.
            filterRuleProtectFolder.EncryptMethod         = (int)FilterAPI.EncryptionMethod.ENCRYPT_FILE_WITH_SAME_KEY_AND_UNIQUE_IV;
            filterRuleProtectFolder.EncryptionPassPhrase  = GlobalConfig.MasterPassword;

            //for whitelist process, it has maximum acess rights.
            if (GlobalConfig.ProtectFolderWhiteList == "*")
            {
                //allow all processes to read the encrypted file except the black list processes.
                filterRuleProtectFolder.AccessFlag |= (uint)(FilterAPI.AccessFlag.ALLOW_READ_ENCRYPTED_FILES);
            }
            else
            {
                //for whitelist process, it has maximum acess rights.
                whiteList = GlobalConfig.ProtectFolderWhiteList.Split(new char[] { ';' });
                if (whiteList.Length > 0)
                {
                    foreach (string authorizedUser in whiteList)
                    {
                        if (authorizedUser.Trim().Length > 0)
                        {
                            filterRuleProtectFolder.ProcessRights += ";" + authorizedUser + "!" + FilterAPI.ALLOW_MAX_RIGHT_ACCESS.ToString();
                        }
                    }
                }
            }

            //for blacklist process, it has maximum acess rights.
            blacklist = GlobalConfig.ProtectFolderBlackList.Split(new char[] { ';' });
            if (blacklist.Length > 0)
            {
                foreach (string unAuthorizedUser in blacklist)
                {
                    if (unAuthorizedUser.Trim().Length > 0)
                    {
                        //can't read the encrypted files
                        uint accessFlag = FilterAPI.ALLOW_MAX_RIGHT_ACCESS & (uint)(~FilterAPI.AccessFlag.ALLOW_READ_ENCRYPTED_FILES);
                        filterRuleProtectFolder.ProcessRights += ";" + unAuthorizedUser + "!" + accessFlag.ToString();
                    }
                }
            }

            GlobalConfig.AddFilterRule(filterRuleShareFolder);
            GlobalConfig.AddFilterRule(filterRuleProtectFolder);

            //send the filter rule settings to the filter driver here.
            GlobalConfig.SaveConfigSetting();
        }
        private void toolStripMenuItem_Start_Click(object sender, EventArgs e)
        {
            try
            {
                if (null == toolStripMenuItem_Start.Tag || (bool)toolStripMenuItem_Start.Tag == false)
                {
                    string secureFolder = string.Empty;

                    if (GlobalConfig.FilterRules.Count > 0)
                    {
                        string includeFilterMask = GlobalConfig.FilterRules.First().Key;

                        if (includeFilterMask.EndsWith("\\*"))
                        {
                            secureFolder = includeFilterMask.Remove(includeFilterMask.IndexOf("\\*"));
                        }
                    }

                    ShareFileFolderInputForm secureFolderForm = new ShareFileFolderInputForm(secureFolder);

                    if (secureFolderForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        secureFolder = secureFolderForm.dropFolder;
                    }

                    if (!Directory.Exists(secureFolder))
                    {
                        ShowNotification("The folder " + secureFolder + " doesn't exist.", true);
                        return;
                    }


                    FilterRule filterRule = new FilterRule();

                    filterRule.IncludeFileFilterMask = secureFolder + "\\*";
                    filterRule.AccessFlag           |= (uint)FilterAPI.AccessFlag.FILE_ENCRYPTION_RULE | FilterAPI.ALLOW_MAX_RIGHT_ACCESS;
                    GlobalConfig.AddFilterRule(filterRule);

                    FilterRule filterRule2 = new FilterRule();
                    filterRule2.IncludeFileFilterMask = secureFolder + "\\*" + DigitalRightControl.SECURE_SHARE_FILE_EXTENSION;
                    filterRule2.AccessFlag            = FilterAPI.ALLOW_MAX_RIGHT_ACCESS;
                    filterRule2.EventType             = (uint)FilterAPI.EVENTTYPE.CREATED | (uint)FilterAPI.EVENTTYPE.RENAMED;
                    GlobalConfig.AddFilterRule(filterRule2);

                    GlobalConfig.SaveConfigSetting();

                    if (!accessControlForm.StartFilterService())
                    {
                        return;
                    }
                    else
                    {
                        toolStripMenuItem_Start.Tag  = true;
                        toolStripMenuItem_Start.Text = "Stop secure agent";
                    }
                }
                else
                {
                    FilterAPI.StopFilter();

                    toolStripMenuItem_Start.Tag  = false;
                    toolStripMenuItem_Start.Text = "Start secure agent";
                }
            }
            catch (Exception ex)
            {
                FilterAPI.StopFilter();
                EventManager.WriteMessage(157, "start service", EventLevel.Error, "start service failed with error:" + ex.Message);
            }
        }