private void UpdateTokenData() { UserGroup user = _token.GetUser(); txtUsername.Text = user.GetName(); txtUserSid.Text = user.Sid.ToString(); TokenType tokentype = _token.GetTokenType(); txtTokenType.Text = _token.GetTokenType().ToString(); TokenLibrary.TokenImpersonationLevel implevel = _token.GetImpersonationLevel(); txtImpLevel.Text = implevel.ToString(); txtTokenId.Text = FormatLuid(_token.GetTokenId()); txtModifiedId.Text = FormatLuid(_token.GetModifiedId()); txtAuthId.Text = FormatLuid(_token.GetAuthenticationId()); if (Enum.IsDefined(typeof(TokenLibrary.TokenIntegrityLevel), _token.GetTokenIntegrityLevel())) { comboBoxIL.SelectedItem = _token.GetTokenIntegrityLevel(); comboBoxILForDup.SelectedItem = _token.GetTokenIntegrityLevel(); } else { comboBoxIL.Text = _token.GetTokenIntegrityLevel().ToString(); comboBoxILForDup.Text = _token.GetTokenIntegrityLevel().ToString(); } txtSessionId.Text = _token.GetSessionId().ToString(); txtSourceName.Text = _token.GetSourceName(); txtSourceId.Text = FormatLuid(_token.GetSourceId()); TokenElevationType evtype = _token.GetElevationType(); txtElevationType.Text = evtype.ToString(); txtIsElevated.Text = _token.IsElevated().ToString(); txtOriginLoginId.Text = FormatLuid(_token.GetTokenOriginId()); btnLinkedToken.Enabled = evtype != TokenElevationType.Default; UpdateGroupList(); txtPrimaryGroup.Text = _token.GetPrimaryGroup().GetName(); txtOwner.Text = _token.GetDefaultOwner().GetName(); RawAcl defdacl = _token.GetDefaultDacl(); if (defdacl != null) { foreach (GenericAce ace in defdacl) { KnownAce kace = ace as KnownAce; if (kace != null) { UserGroup group = new UserGroup(kace.SecurityIdentifier, GroupFlags.None); ListViewItem item = new ListViewItem(group.GetName()); uint mask = (uint)(GenericAccessRights.GenericAll | GenericAccessRights.GenericExecute | GenericAccessRights.GenericRead | GenericAccessRights.GenericWrite); string maskstr; if (((uint)kace.AccessMask & ~mask) != 0) { maskstr = String.Format("0x{0:X08}", kace.AccessMask); } else { GenericAccessRights generic = (GenericAccessRights)kace.AccessMask; maskstr = generic.ToString(); } item.SubItems.Add(maskstr); item.SubItems.Add(kace.AceFlags.ToString()); item.SubItems.Add(kace.AceType.ToString()); listViewDefDacl.Items.Add(item); } } } else { listViewDefDacl.Items.Add("No Default DACL"); } listViewDefDacl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); listViewDefDacl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); if (_token.IsRestricted()) { PopulateGroupList(listViewRestrictedSids, _token.GetRestrictedSids()); } else { tabControlMain.TabPages.Remove(tabPageRestricted); } if (_token.IsAppContainer()) { PopulateGroupList(listViewCapabilities, _token.GetCapabilities()); txtACNumber.Text = _token.GetAppContainerNumber().ToString(); txtPackageSid.Text = _token.GetPackageSid().GetName(); } else { tabControlMain.TabPages.Remove(tabPageAppContainer); } txtUIAccess.Text = _token.IsUIAccess().ToString(); txtSandboxInert.Text = _token.IsSandboxInert().ToString(); bool virtAllowed = _token.IsVirtualizationAllowed(); txtVirtualizationAllowed.Text = virtAllowed.ToString(); if (virtAllowed) { txtVirtualizationEnabled.Text = _token.IsVirtualizationEnabled().ToString(); } else { txtVirtualizationEnabled.Text = "N/A"; } txtMandatoryILPolicy.Text = _token.GetIntegrityLevelPolicy().ToString(); UpdatePrivileges(); }
private void UpdateTokenData() { UserGroup user = _token.User; txtUsername.Text = user.ToString(); txtUserSid.Text = user.Sid.ToString(); TokenType tokentype = _token.TokenType; txtTokenType.Text = _token.TokenType.ToString(); if (_token.TokenType == TokenType.Impersonation) { SecurityImpersonationLevel implevel = _token.ImpersonationLevel; txtImpLevel.Text = implevel.ToString(); } else { txtImpLevel.Text = "N/A"; } txtTokenId.Text = _token.Id.ToString(); txtModifiedId.Text = _token.ModifiedId.ToString(); txtAuthId.Text = _token.AuthenticationId.ToString(); if (Enum.IsDefined(typeof(TokenIntegrityLevel), _token.IntegrityLevel)) { comboBoxIL.SelectedItem = _token.IntegrityLevel; comboBoxILForDup.SelectedItem = _token.IntegrityLevel; } else { comboBoxIL.Text = _token.IntegrityLevel.ToString(); comboBoxILForDup.Text = _token.IntegrityLevel.ToString(); } txtSessionId.Text = _token.SessionId.ToString(); if (_token.IsAccessGranted(TokenAccessRights.QuerySource)) { txtSourceName.Text = _token.Source.SourceName; txtSourceId.Text = _token.Source.SourceIdentifier.ToString(); } else { txtSourceName.Text = "N/A"; txtSourceId.Text = "N/A"; } TokenElevationType evtype = _token.ElevationType; txtElevationType.Text = evtype.ToString(); txtIsElevated.Text = _token.Elevated.ToString(); txtOriginLoginId.Text = _token.Origin.ToString(); btnLinkedToken.Enabled = evtype != TokenElevationType.Default; UpdateGroupList(); txtPrimaryGroup.Text = _token.PrimaryGroup.Name; txtOwner.Text = _token.Owner.Name; Acl defdacl = _token.DefaultDacl; if (!defdacl.NullAcl) { foreach (Ace ace in defdacl) { UserGroup group = new UserGroup(ace.Sid, GroupAttributes.None); ListViewItem item = new ListViewItem(group.ToString()); AccessMask mask = GenericAccessRights.GenericAll | GenericAccessRights.GenericExecute | GenericAccessRights.GenericRead | GenericAccessRights.GenericWrite; string maskstr; if ((ace.Mask & ~mask).HasAccess) { maskstr = $"0x{ace.Mask:X08}"; } else { maskstr = ace.Mask.ToGenericAccess().ToString(); } item.SubItems.Add(maskstr); item.SubItems.Add(ace.Flags.ToString()); item.SubItems.Add(ace.Type.ToString()); listViewDefDacl.Items.Add(item); } } else { listViewDefDacl.Items.Add("No Default DACL"); } listViewDefDacl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); listViewDefDacl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); if (_token.Restricted) { PopulateGroupList(listViewRestrictedSids, _token.RestrictedSids); } else { tabControlMain.TabPages.Remove(tabPageRestricted); } if (_token.AppContainer) { PopulateGroupList(listViewCapabilities, _token.Capabilities); txtACNumber.Text = _token.AppContainerNumber.ToString(); txtPackageName.Text = _token.AppContainerSid.Name; txtPackageSid.Text = _token.AppContainerSid.ToString(); } else { tabControlMain.TabPages.Remove(tabPageAppContainer); } txtUIAccess.Text = _token.UIAccess.ToString(); txtSandboxInert.Text = _token.SandboxInert.ToString(); bool virtAllowed = _token.VirtualizationAllowed; txtVirtualizationAllowed.Text = virtAllowed.ToString(); btnToggleVirtualizationEnabled.Enabled = virtAllowed; if (virtAllowed) { txtVirtualizationEnabled.Text = _token.VirtualizationEnabled.ToString(); } else { txtVirtualizationEnabled.Text = "N/A"; } txtMandatoryILPolicy.Text = _token.MandatoryPolicy.ToString(); txtHandleAccess.Text = _token.GrantedAccess.ToString(); Sid trust_level = _token.TrustLevel; txtTrustLevel.Text = trust_level != null ? trust_level.Name : "N/A"; UpdatePrivileges(); UpdateSecurityAttributes(); if (_token.IsAccessGranted(TokenAccessRights.ReadControl)) { securityDescriptorViewerControl.SetSecurityDescriptor(_token.SecurityDescriptor, _token.NtType, _token.NtType.ValidAccess); } else { tabControlMain.TabPages.Remove(tabPageSecurity); } }
private void UpdateTokenData() { UserGroup user = _token.User; txtUsername.Text = user.ToString(); txtUserSid.Text = user.Sid.ToString(); TokenType tokentype = _token.TokenType; txtTokenType.Text = _token.TokenType.ToString(); if (_token.TokenType == TokenType.Impersonation) { SecurityImpersonationLevel implevel = _token.ImpersonationLevel; txtImpLevel.Text = implevel.ToString(); } else { txtImpLevel.Text = "N/A"; } txtTokenId.Text = FormatLuid(_token.Id); txtModifiedId.Text = FormatLuid(_token.ModifiedId); txtAuthId.Text = FormatLuid(_token.AuthenticationId); if (Enum.IsDefined(typeof(TokenIntegrityLevel), _token.IntegrityLevel)) { comboBoxIL.SelectedItem = _token.IntegrityLevel; comboBoxILForDup.SelectedItem = _token.IntegrityLevel; } else { comboBoxIL.Text = _token.IntegrityLevel.ToString(); comboBoxILForDup.Text = _token.IntegrityLevel.ToString(); } txtSessionId.Text = _token.SessionId.ToString(); txtSourceName.Text = _token.Source.SourceName; txtSourceId.Text = FormatLuid(_token.Source.SourceIdentifier); TokenElevationType evtype = _token.ElevationType; txtElevationType.Text = evtype.ToString(); txtIsElevated.Text = _token.Elevated.ToString(); txtOriginLoginId.Text = FormatLuid(_token.Origin); btnLinkedToken.Enabled = evtype != TokenElevationType.Default; UpdateGroupList(); txtPrimaryGroup.Text = _token.PrimaryGroup.Name; txtOwner.Text = _token.Owner.Name; Acl defdacl = _token.DefaultDalc; if (!defdacl.NullAcl) { foreach (Ace ace in defdacl) { UserGroup group = new UserGroup(ace.Sid, GroupAttributes.None); ListViewItem item = new ListViewItem(group.ToString()); uint mask = (uint)(GenericAccessRights.GenericAll | GenericAccessRights.GenericExecute | GenericAccessRights.GenericRead | GenericAccessRights.GenericWrite); string maskstr; if (((uint)ace.Mask & ~mask) != 0) { maskstr = String.Format("0x{0:X08}", ace.Mask); } else { GenericAccessRights generic = (GenericAccessRights)ace.Mask; maskstr = generic.ToString(); } item.SubItems.Add(maskstr); item.SubItems.Add(ace.AceFlags.ToString()); item.SubItems.Add(ace.AceType.ToString()); listViewDefDacl.Items.Add(item); } } else { listViewDefDacl.Items.Add("No Default DACL"); } listViewDefDacl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); listViewDefDacl.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); if (_token.Restricted) { PopulateGroupList(listViewRestrictedSids, _token.RestrictedSids); } else { tabControlMain.TabPages.Remove(tabPageRestricted); } if (_token.AppContainer) { PopulateGroupList(listViewCapabilities, _token.Capabilities); txtACNumber.Text = _token.AppContainerNumber.ToString(); txtPackageSid.Text = _token.AppContainerSid.Name; } else { tabControlMain.TabPages.Remove(tabPageAppContainer); } txtUIAccess.Text = _token.UiAccess.ToString(); txtSandboxInert.Text = _token.SandboxInert.ToString(); bool virtAllowed = _token.VirtualizationAllowed; txtVirtualizationAllowed.Text = virtAllowed.ToString(); if (virtAllowed) { txtVirtualizationEnabled.Text = _token.VirtualizationEnabled.ToString(); } else { txtVirtualizationEnabled.Text = "N/A"; } txtMandatoryILPolicy.Text = _token.MandatoryPolicy.ToString(); UpdatePrivileges(); UpdateSecurityAttributes(); }