示例#1
0
        static void CheckAccess(string path, byte[] sd, ObjectTypeInfo type)
        {
            try
            {
                if (_type_filter.Count > 0)
                {
                    if (!_type_filter.Contains(type.Name.ToLower()))
                    {
                        return;
                    }
                }

                if (sd.Length > 0)
                {
                    uint granted_access = 0;

                    if (_dir_rights != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, type, (uint)_dir_rights, sd);
                    }
                    else
                    {
                        granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                    }

                    if (granted_access != 0)
                    {
                        // As we can get all the righs for the key get maximum
                        if (_dir_rights != 0)
                        {
                            granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                        }

                        if (!_show_write_only || type.HasWritePermission(granted_access))
                        {
                            Console.WriteLine("<{0}> {1} : {2:X08} {3}", type.Name, path, granted_access, AccessMaskToString(type, granted_access));
                            if (_print_sddl)
                            {
                                Console.WriteLine("{0}", NativeBridge.GetStringSecurityDescriptor(sd));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#2
0
        static void CheckAccess(FileSystemInfo entry)
        {
            try
            {
                byte[] sd = NativeBridge.GetNamedSecurityDescriptor(entry.FullName, "file");
                if (sd.Length > 0)
                {
                    bool is_dir = entry is DirectoryInfo;
                    uint granted_access;

                    if (is_dir && _dir_filter != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, _type, _dir_filter, sd);
                    }
                    else if (!is_dir && _file_filter != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, _type, _file_filter, sd);
                    }
                    else
                    {
                        granted_access = NativeBridge.GetMaximumAccess(_token, _type, sd);
                    }

                    if (granted_access != 0)
                    {
                        // Now reget maximum access rights
                        if (_dir_filter != 0 || _file_filter != 0)
                        {
                            granted_access = NativeBridge.GetMaximumAccess(_token, _type, sd);
                        }

                        if (!_show_write_only || _type.HasWritePermission(granted_access))
                        {
                            Console.WriteLine("{0}{1} : {2:X08} {3}", entry.FullName, is_dir ? "\\" : "", granted_access, AccessMaskToString(granted_access, is_dir));
                            if (_print_sddl)
                            {
                                Console.WriteLine("{0}", NativeBridge.GetStringSecurityDescriptor(sd));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        static void CheckAccess(string name)
        {
            try
            {
                byte[] sd = NativeBridge.GetNamedSecurityDescriptor(MapKeyName(name), "key");
                if (sd.Length > 0)
                {
                    uint granted_access = 0;

                    if (_key_rights != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, _type, _key_rights, sd);
                    }
                    else
                    {
                        granted_access = NativeBridge.GetMaximumAccess(_token, _type, sd);
                    }

                    if (granted_access != 0)
                    {
                        // As we can get all the righs for the key get maximum
                        if (_key_rights != 0)
                        {
                            granted_access = NativeBridge.GetMaximumAccess(_token, _type, sd);
                        }

                        if (!_show_write_only || _type.HasWritePermission(granted_access))
                        {
                            Console.WriteLine("{0} : {1:X08} {2}", name, granted_access, AccessMaskToString(granted_access));
                            if (_print_sddl)
                            {
                                Console.WriteLine("{0}", NativeBridge.GetStringSecurityDescriptor(sd));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        static void CheckAccess(string path, byte[] sd, ObjectTypeInfo type)
        {
            try
            {
                if (_type_filter.Count > 0)
                {
                    if (!_type_filter.Contains(type.Name.ToLower()))
                    {
                        return;
                    }
                }

                if (sd.Length > 0)
                {
                    uint granted_access = 0;

                    if (_dir_rights != 0)
                    {
                        granted_access = NativeBridge.GetAllowedAccess(_token, type, (uint)_dir_rights, sd);
                    }
                    else
                    {
                        granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                    }

                    if (granted_access != 0)
                    {
                        // As we can get all the righs for the key get maximum
                        if (_dir_rights != 0)
                        {
                            granted_access = NativeBridge.GetMaximumAccess(_token, type, sd);
                        }

                        if (!_show_write_only || type.HasWritePermission(granted_access))
                        {
                            Console.WriteLine("<{0}> {1} : {2:X08} {3}", type.Name, path, granted_access, AccessMaskToString(type, granted_access));
                            if (_print_sddl)
                            {
                                Console.WriteLine("{0}", NativeBridge.GetStringSecurityDescriptor(sd));
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }