예제 #1
0
 public void DumpAddGroup(
     string name,
     SidAttributes attributes
     )
 {
     _groups.DumpAddGroup(name, attributes);
 }
예제 #2
0
        public SecurityIdentifier(IdentifierAuthority authority, uint[] subs, SidAttributes attributes)
        {
            this.authority = authority;
            subAuthorities = subs;

            Attributes = attributes;
        }
        private string GetAttributeString(SidAttributes Attributes)
        {
            string text = string.Empty;

            if ((Attributes & SidAttributes.Integrity) != 0)
            {
                if ((Attributes & SidAttributes.IntegrityEnabled) != 0)
                    return "Integrity";
                
                return "Integrity (Disabled)";
            }
            
            if ((Attributes & SidAttributes.LogonId) != 0)
                text = "Logon ID";
            else if ((Attributes & SidAttributes.Mandatory) != 0)
                text = "Mandatory";
            else if ((Attributes & SidAttributes.Owner) != 0)
                text = "Owner";
            else if ((Attributes & SidAttributes.Resource) != 0)
                text = "Resource";
            else if ((Attributes & SidAttributes.UseForDenyOnly) != 0)
                text = "Use for Deny Only";

            if ((Attributes & SidAttributes.EnabledByDefault) != 0)
                return text + " (Default Enabled)";
            
            if ((Attributes & SidAttributes.Enabled) != 0)
                return text;
            
            return text + " (Disabled)";
        }
예제 #4
0
        private Color GetAttributeColor(SidAttributes Attributes)
        {
            if ((Attributes & SidAttributes.Integrity) != 0)
            {
                if ((Attributes & SidAttributes.IntegrityEnabled) == 0)
                {
                    return(Color.FromArgb(0xe0e0e0));
                }
                else
                {
                    return(Color.White);
                }
            }

            if ((Attributes & SidAttributes.EnabledByDefault) != 0)
            {
                return(Color.FromArgb(0xe0f0e0));
            }
            else if ((Attributes & SidAttributes.Enabled) != 0)
            {
                return(Color.White);
            }
            else
            {
                return(Color.FromArgb(0xf0e0e0));
            }
        }
        public void DumpAddGroup(string name, SidAttributes attributes)
        {
            ListViewItem item = listGroups.Items.Add(new ListViewItem());

            item.Text = PhUtils.GetBestUserName(name, Settings.Instance.ShowAccountDomains);
            item.BackColor = GetAttributeColor(attributes);
            item.SubItems.Add(new ListViewItem.ListViewSubItem(item, GetAttributeString(attributes)));
        }
예제 #6
0
        public void DumpAddGroup(string name, SidAttributes attributes)
        {
            ListViewItem item = listGroups.Items.Add(new ListViewItem());

            item.Text      = PhUtils.GetBestUserName(name, Settings.Instance.ShowAccountDomains);
            item.BackColor = GetAttributeColor(attributes);
            item.SubItems.Add(new ListViewItem.ListViewSubItem(item, GetAttributeString(attributes)));
        }
예제 #7
0
        public static SecurityIdentifier FromRpcSid(RpcSid sid, uint id = 0, SidAttributes attributes = 0)
        {
            if (sid == null)
            {
                throw new ArgumentNullException(nameof(sid));
            }

            return(new SecurityIdentifier(sid.IdentifierAuthority.Authority, Concat(sid.SubAuthority, id), attributes));
        }
예제 #8
0
        public SecurityIdentifier(IdentifierAuthority authority, int[] subs, SidAttributes attributes)
        {
            this.authority = authority;
            SubAuthorities = subs;

            Attributes = attributes;

            BinaryForm = ToBinaryForm(authority, subs);
        }
예제 #9
0
        private Sid(IntPtr sid, bool hasAttributes, SidAttributes attributes, string systemName)
        {
            _memory = new MemoryAlloc(Win32.RtlLengthSid(sid));

            Win32.RtlCopySid(_memory.Size, _memory, sid).ThrowIf();

            _hasAttributes = hasAttributes;
            _attributes    = attributes;
            _systemName    = systemName;
        }
예제 #10
0
        public void Unmarshal(NdrBuffer buffer)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            this.RelativeId = buffer.ReadUInt32LittleEndian();
            this.Attributes = (SidAttributes)buffer.ReadInt32LittleEndian();
        }
예제 #11
0
        public void Unmarshal(NdrBuffer buffer)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            buffer.ReadConformantStruct <RpcSid>(p => this.Sid = p);

            this.Attributes = (SidAttributes)buffer.ReadInt32LittleEndian();
        }
예제 #12
0
        public SecurityIdentifier(ReadOnlySpan <byte> binary, SidAttributes attributes = 0)
        {
            BinaryForm = new ReadOnlyMemory <byte>(binary.ToArray());

            authority  = (IdentifierAuthority)binary.Slice(2, 6).AsLong();
            Attributes = attributes;

            SubAuthorities = new int[binary[1]];

            for (var i = 0; i < SubAuthorities.Length; i++)
            {
                SubAuthorities[i] = (int)binary.Slice(8 + (4 * i), 4).AsLong(littleEndian: true);
            }
        }
예제 #13
0
        private string GetAttributeString(SidAttributes Attributes)
        {
            string text = "";

            if ((Attributes & SidAttributes.Integrity) != 0)
            {
                if ((Attributes & SidAttributes.IntegrityEnabled) != 0)
                {
                    return("Integrity");
                }
                else
                {
                    return("Integrity (Disabled)");
                }
            }
            else if ((Attributes & SidAttributes.LogonId) != 0)
            {
                text = "Logon ID";
            }
            else if ((Attributes & SidAttributes.Mandatory) != 0)
            {
                text = "Mandatory";
            }
            else if ((Attributes & SidAttributes.Owner) != 0)
            {
                text = "Owner";
            }
            else if ((Attributes & SidAttributes.Resource) != 0)
            {
                text = "Resource";
            }
            else if ((Attributes & SidAttributes.UseForDenyOnly) != 0)
            {
                text = "Use for Deny Only";
            }

            if ((Attributes & SidAttributes.EnabledByDefault) != 0)
            {
                return(text + " (Default Enabled)");
            }
            else if ((Attributes & SidAttributes.Enabled) != 0)
            {
                return(text);
            }
            else
            {
                return(text + " (Disabled)");
            }
        }
예제 #14
0
        private Sid(IntPtr sid, bool hasAttributes, SidAttributes attributes, string systemName)
        {
            NtStatus status;

            _memory = new MemoryAlloc(Win32.RtlLengthSid(sid));

            if ((status = Win32.RtlCopySid(_memory.Size, _memory, sid)) >= NtStatus.Error)
            {
                Win32.ThrowLastError(status);
            }

            _hasAttributes = hasAttributes;
            _attributes    = attributes;
            _systemName    = systemName;
        }
예제 #15
0
        public SecurityIdentifier(byte[] binary, SidAttributes attributes = 0)
        {
            BinaryForm = binary;

            var span = new Span <byte>(binary);

            authority  = (IdentifierAuthority)span.Slice(2, 6).AsLong();
            Attributes = attributes;

            SubAuthorities = new int[binary[1]];

            for (var i = 0; i < SubAuthorities.Length; i++)
            {
                SubAuthorities[i] = (int)span.Slice(8 + (4 * i), 4).AsLong(littleEndian: true);
            }
        }
예제 #16
0
        private Color GetAttributeColor(SidAttributes Attributes)
        {
            if ((Attributes & SidAttributes.Integrity) != 0)
            {
                if ((Attributes & SidAttributes.IntegrityEnabled) == 0)
                    return Color.FromArgb(0xe0e0e0);
                else
                    return Color.White;
            }

            if ((Attributes & SidAttributes.EnabledByDefault) != 0)
                return Color.FromArgb(0xe0f0e0);
            else if ((Attributes & SidAttributes.Enabled) != 0)
                return Color.White;
            else
                return Color.FromArgb(0xf0e0e0);
        }
예제 #17
0
        public SecurityIdentifier(byte[] binary, SidAttributes attributes = 0)
        {
            authority  = (IdentifierAuthority)BytesToLong(binary, 2, 5);
            Attributes = attributes;

            var subs = new int[binary[1]];

            for (var i = 0; i < binary[1]; i++)
            {
                subs[i] =
                    (int)(
                        (((uint)binary[8 + 4 * i + 0]) << 0) +
                        (((uint)binary[8 + 4 * i + 1]) << 8) +
                        (((uint)binary[8 + 4 * i + 2]) << 16) +
                        (((uint)binary[8 + 4 * i + 3]) << 24)
                        );
            }

            subAuthorities = new int[subs.Length];

            subs.CopyTo(subAuthorities, 0);
        }
예제 #18
0
        private static SecurityIdentifier[] ParseExtraSids(NdrBinaryReader pacStream, int extraSidCount, int extraSidPointer)
        {
            if (extraSidPointer == 0)
            {
                return(new SecurityIdentifier[0]);
            }

            int realExtraSidCount = pacStream.ReadInt();

            if (realExtraSidCount != extraSidCount)
            {
                throw new InvalidDataException($"Expected Sid count {extraSidCount} doesn't match actual sid count {realExtraSidCount}");
            }

            var extraSidAtts = new SecurityIdentifier[extraSidCount];

            var pointers   = new int[extraSidCount];
            var attributes = new SidAttributes[extraSidCount];

            for (int i = 0; i < extraSidCount; i++)
            {
                pointers[i]   = pacStream.ReadInt();
                attributes[i] = (SidAttributes)pacStream.ReadUnsignedInt();
            }

            for (int i = 0; i < extraSidCount; i++)
            {
                SecurityIdentifier sid = null;

                if (pointers[i] != 0)
                {
                    sid = new SecurityIdentifier(pacStream.ReadSid(), attributes[i]);
                }

                extraSidAtts[i] = sid;
            }

            return(extraSidAtts);
        }
예제 #19
0
        public void Unmarshal(NdrBuffer buffer)
        {
            buffer.ReadConformantStruct <RpcSid>(p => Sid = p);

            Attributes = (SidAttributes)buffer.ReadInt32LittleEndian();
        }
예제 #20
0
 public void Unmarshal(NdrBuffer buffer)
 {
     RelativeId = buffer.ReadUInt32LittleEndian();
     Attributes = (SidAttributes)buffer.ReadInt32LittleEndian();
 }
예제 #21
0
 public SidAndAttributes(SidAttributes attributes, IntPtr sid)
 {
     _securityIdentifier = new SecurityIdentifier(sid);
     _attributes         = attributes;
 }
예제 #22
0
 public SecurityIdentifier(SecurityIdentifier sid, SidAttributes attributes)
     : this(sid.authority, sid.SubAuthorities, attributes)
 {
 }
예제 #23
0
 public void DumpAddGroup(
     string name,
     SidAttributes attributes
     )
 {
     _groups.DumpAddGroup(name, attributes);
 }
예제 #24
0
 public SidAndAttributes(SidAttributes attributes, IntPtr sid)
 {
     _securityIdentifier = new SecurityIdentifier(sid);
     _attributes = attributes;
 }
예제 #25
0
 /// <summary>
 /// Copies the specified SID.
 /// </summary>
 /// <param name="sid">A pointer to an existing SID.</param>
 /// <param name="attributes">The attributes associated with the SID.</param>
 /// <param name="systemName">The name of the system on which the SID is located.</param>
 public Sid(IntPtr sid, SidAttributes attributes, string systemName)
     : this(sid, true, attributes, systemName)
 {
 }
예제 #26
0
 /// <summary>
 /// Copies the specified SID.
 /// </summary>
 /// <param name="sid">A pointer to an existing SID.</param>
 /// <param name="attributes">The attributes associated with the SID.</param>
 public Sid(IntPtr sid, SidAttributes attributes)
     : this(sid, attributes, null)
 {
 }
예제 #27
0
 public static SecurityIdentifier FromRpcSid(RpcSid sid, int id = 0, SidAttributes attributes = 0)
 {
     return(new SecurityIdentifier(sid.IdentifierAuthority.Authority, Concat(sid.SubAuthority, id), attributes));
 }
예제 #28
0
 public SidAndAttributes(SID sid, SidAttributes attributes)
 {
     Sid        = sid;
     Attributes = attributes;
 }