HackTricks
Search…
Pentesting
Powered By GitBook
Access Tokens

Access Tokens

Each user logged onto the system holds an access token with security information for that logon session. The system creates an access token when the user logs on. Every process executed on behalf of the user has a copy of the access token. The token identifies the user, the user's groups, and the user's privileges. A token also contains a logon SID (Security Identifier) that identifies the current logon session.
You can see this information executing whoami /all
1
whoami /all
2
3
USER INFORMATION
4
----------------
5
6
User Name SID
7
===================== ============================================
8
desktop-rgfrdxl\cpolo S-1-5-21-3359511372-53430657-2078432294-1001
9
10
11
GROUP INFORMATION
12
-----------------
13
14
Group Name Type SID Attributes
15
============================================================= ================ ============================================================================================================= ==================================================
16
Mandatory Label\Medium Mandatory Level Label S-1-16-8192
17
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
18
NT AUTHORITY\Local account and member of Administrators group Well-known group S-1-5-114 Group used for deny only
19
BUILTIN\Administrators Alias S-1-5-32-544 Group used for deny only
20
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
21
BUILTIN\Performance Log Users Alias S-1-5-32-559 Mandatory group, Enabled by default, Enabled group
22
NT AUTHORITY\INTERACTIVE Well-known group S-1-5-4 Mandatory group, Enabled by default, Enabled group
23
CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group
24
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
25
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
26
MicrosoftAccount\[email protected] User S-1-11-96-3623454863-58364-18864-2661722203-1597581903-3158937479-2778085403-3651782251-2842230462-2314292098 Mandatory group, Enabled by default, Enabled group
27
NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group
28
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
29
NT AUTHORITY\Cloud Account Authentication Well-known group S-1-5-64-36 Mandatory group, Enabled by default, Enabled group
30
31
32
PRIVILEGES INFORMATION
33
----------------------
34
35
Privilege Name Description State
36
============================= ==================================== ========
37
SeShutdownPrivilege Shut down the system Disabled
38
SeChangeNotifyPrivilege Bypass traverse checking Enabled
39
SeUndockPrivilege Remove computer from docking station Disabled
40
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
41
SeTimeZonePrivilege Change the time zone Disabled
Copied!
or using Process Explorer from Sysinternals (select process and access"Security" tab):

Local administrator

When a local administrator logins, two access tokens are created: One with admin rights and other one with normal rights. By default, when this user executes a process the one with regular (non-administrator) rights is used. When this user tries to execute anything as administrator ("Run as Administrator" for example) the UAC will be used to ask for permission. If you want to learn more about the UAC read this page.

Credentials user impersonation

If you have valid credentials of any other user, you can create a new logon session with those credentials :
1
runas /user:domain\username cmd.exe
Copied!
The access token has also a reference of the logon sessions inside the LSASS, this is useful if the process needs to access some objects of the network. You can launch a process that uses different credentials for accessing network services using:
1
runas /user:domain\username /netonly cmd.exe
Copied!
This is useful if you have useful credentials to access objects in the network but those credentials aren't valid inside the current host as they are only going to be used in the network (in the current host your current user privileges will be used).

Types of tokens

There are two types of tokens available:
    Primary token: Primary tokens can only be associated to processes, and they represent a process's security subject. The creation of primary tokens and their association to processes are both privileged operations, requiring two different privileges in the name of privilege separation - the typical scenario sees the authentication service creating the token, and a logon service associating it to the user's operating system shell. Processes initially inherit a copy of the parent process's primary token.
    Impersonation token: Impersonation is a security concept implemented in Windows NT that allows a server application to temporarily "be" the client in terms of access to secure objects. Impersonation has four possible levels:
      anonymous, giving the server the access of an anonymous/unidentified user
      identification, letting the server inspect the client's identity but not use that identity to access objects
      impersonation, letting the server act on behalf of the client
      delegation, same as impersonation but extended to remote systems to which the server connects (through the preservation of credentials).
    The client can choose the maximum impersonation level (if any) available to the server as a connection parameter. Delegation and impersonation are privileged operations (impersonation initially was not, but historical carelessness in the implementation of client APIs failing to restrict the default level to "identification", letting an unprivileged server impersonate an unwilling privileged client, called for it). Impersonation tokens can only be associated to threads, and they represent a client process's security subject. Impersonation tokens are usually created and associated to the current thread implicitly, by IPC mechanisms such as DCE RPC, DDE and named pipes.

Impersonate Tokens

Using the incognito module of metasploit if you have enough privileges you can easily list and impersonate other tokens. This could be useful to perform actions as if you where the other user. You could also escalate privileges with this technique.

Token Privileges

References

Last modified 1yr ago