コード例 #1
0
        private NtToken CreateLowBoxToken(NtToken token)
        {
            Sid package_sid = TokenUtils.GetPackageSidFromName(textBoxPackageSid.Text);

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

            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 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);
            }

            if (AppContainer)
            {
                return(TokenUtils.CreateAppContainerToken(token, package_sid, GetCapabilitySids()));
            }

            return(token.CreateLowBoxToken(package_sid, GetCapabilitySids(),
                                           Handle ?? new NtObject[0], TokenAccessRights.MaximumAllowed));
        }