Esempio n. 1
0
        static void PrivilegeRights(Security security, ObservableCollection<ItemSecurityTested> itemsSecurityTested)
        {
            string categorieName = CategorieSecurity.Categories[Convert.ToInt32(eSecurity.PrivilegeRights)];

            Console.WriteLine("PrivilegeRights");
            foreach (var item in security.PrivilegeRights)
            {
                if (item.Activated)
                    itemsSecurityTested.Add(ItemSecurityTested.Create(categorieName, item.Key, item.Value, item.Value, true));
            }
        }
Esempio n. 2
0
        public void CheckSecurity(Security security, List<string> securitysChecked)
        {
            int i;

            this._itemsSecurityTested.Clear();
            foreach (var securityChecked in securitysChecked)
            {
                i = 0;
                while ((i <= CategorieSecurity.Categories.Length) && (CategorieSecurity.Categories[i] != securityChecked))
                    ++i;
                Tester.delegates[i](security, this._itemsSecurityTested);
            }
        }
Esempio n. 3
0
		public void Start()
		{
			if (System.IO.File.Exists(this._saveFileName))
				this._security = Parser.DeserializeFromBinaryToObject<Security>(this._saveFileName);
			securityTest.CheckEvent += securityTest_CheckEvent;
			settingProperty.SaveEvent += settingProperty_SaveEvent;
			securityTest.SettingEvent += securityTest_SettingEvent;

			this._categoriesSettings = new ObservableCollection<ItemSecurity>[]
			{
				this._security.SystemAccess, this._security.EventAudit,
				this._security.RegistryValues, this._security.PrivilegeRights, this._security.Version
			};
			for (int i = 0; i < CategorieSecurity.Categories.Length; i++)
				this._categories.Add(ItemCategorieSecurity.Create(CategorieSecurity.Categories[i], true));
			this.securityTest.listView.ItemsSource = this._categories;
		}
Esempio n. 4
0
        static void RegistryValues(Security security, ObservableCollection<ItemSecurityTested> itemsSecurityTested)
        {
            string categorieName = CategorieSecurity.Categories[Convert.ToInt32(eSecurity.RegistryValues)];

            Console.WriteLine("RegistryValues");
            foreach (var item in security.RegistryValues)
            {
                if (item.Activated)
                {
                    string type = item.Value.Substring(0, item.Value.IndexOf(','));
                    string data = item.Value.Substring(item.Value.IndexOf(',') + 1);
                    if (data != string.Empty && data[0] == '\"' && data[data.Length - 1] == '\"')
                        data = data.Substring(1, data.Length - 2);
                    string keyStr = item.Key.Substring(item.Key.IndexOf('\\') + 1, (item.Key.LastIndexOf('\\')) - (item.Key.IndexOf('\\') + 1));
                    //Console.WriteLine(keyStr);
                    using (RegistryKey key = Registry.LocalMachine.OpenSubKey(keyStr))
                    {
                        string ret = string.Empty;
                        if (key != null)
                        {
                            Object ret2 = null;
                            string value = item.Key.Substring(item.Key.LastIndexOf('\\') + 1);
                            try
                            {
                                if (type == "7")
                                    ret2 = (string[])key.GetValue(value, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                                else if (type == "3")
                                    ret2 = (byte[])key.GetValue(value, null);
                                else
                                    ret2 = key.GetValue(value, null);
                            }
                            catch (Exception) { ret2 = key.GetValue(value, null); }
                            if (ret2 is string[])
                                ret = string.Join(",", ret2 as string[]);
                            else if (ret2 is byte[])
                                ret = BitConverter.ToString(ret2 as byte[]);
                            else
                                ret = (ret2 != null) ? Convert.ToString(ret2) : string.Empty;
                        }
                        //Console.WriteLine("ret=>{0}, m.Groups[1].Value=>{1}", ret, data);
                        itemsSecurityTested.Add(ItemSecurityTested.Create(categorieName, item.Key, data, ret, (ret != null && ret == data) ? true : false));
                    }
                }
            }
        }