private NtToken GetLowBoxToken(NtToken token)
        {
            Sid package_sid = TokenUtils.GetPackageSidFromName(PackageSid);

            if (!NtSecurity.IsPackageSid(package_sid))
            {
                throw new ArgumentException($"Invalid Package Sid {package_sid}");
            }

            if (!String.IsNullOrEmpty(RestrictedPackageName))
            {
                package_sid = TokenUtils.DeriveRestrictedPackageSidFromSid(package_sid, RestrictedPackageName);
            }

            IEnumerable <Sid> capability_sids = CapabilitySids == null ? new Sid[0] : CapabilitySids.Select(s =>
            {
                if (!s.StartsWith("S-"))
                {
                    return(NtSecurity.GetCapabilitySid(s));
                }
                Sid sid = new Sid(s);
                if (!NtSecurity.IsCapabilitySid(sid))
                {
                    throw new ArgumentException($"{s} is not a capability SID", s);
                }
                return(sid);
            }
                                                                                                            );

            return(token.CreateLowBoxToken(package_sid, capability_sids, Handles ?? new NtObject[0], TokenAccessRights.MaximumAllowed));
        }
Exemplo n.º 2
0
        private NtToken CreateLowBoxToken(NtToken token)
        {
            Sid package_sid = TokenUtils.GetPackageSidFromName(textBoxPackageSid.Text);

            Sid[] capabilities = GetGroupFromList(listViewCapabilities.Items.OfType <ListViewItem>());
            foreach (Sid cap in capabilities)
            {
                if (!NtSecurity.IsCapabilitySid(cap))
                {
                    throw new ArgumentException($"Invalid Capability Sid {cap}");
                }
            }

            return(token.CreateLowBoxToken(package_sid, capabilities,
                                           new NtObject[0], TokenAccessRights.MaximumAllowed));
        }
 private IEnumerable <Sid> GetCapabilitySids()
 {
     return(CapabilitySid == null ? new Sid[0] : CapabilitySid.Select(s =>
     {
         if (!s.StartsWith("S-"))
         {
             return NtSecurity.GetCapabilitySid(s);
         }
         Sid sid = new Sid(s);
         if (!NtSecurity.IsCapabilitySid(sid))
         {
             throw new ArgumentException($"{s} is not a capability SID", s);
         }
         return sid;
     }
                                                                      ));
 }