WinDBG : Process et son Token

petite utilisation de WinDbg…

Par extensions

Processus ‘system’

lkd> !process 0 1 system
PROCESS 82da3648  SessionId: none  Cid: 0004    Peb: 00000000  ParentCid: 0000
    DirBase: 00e02000  ObjectTable: e1001c58  HandleCount: 614.
    Image: System
    VadRoot 82a6e0f0 Vads 4 Clone 0 Private 3. Modified 11050. Locked 0.
    DeviceMap e10000a8
    Token                             e1000758
[...]

Jeton de sécurité du processus

lkd> !token -n 0xe1000758
_TOKEN e1000758
TS Session ID: 0
User: S-1-5-18 (Well Known Group: AUTORITE NT\SYSTEM)
[...]
Authentication ID:         (0,3e7)
Impersonation Level:       Anonymous
TokenType:                 Primary
Source: *SYSTEM*           TokenFlags: 0x89 ( Token NOT in use ) 
Token ID: 3ea              ParentToken ID: 0
Modified ID:               (0, 3e9)
RestrictedSidCount: 0      RestrictedSids: 00000000
OriginatingLogonSession: 0

Par accès direct en mémoire

Processus ‘system’

lkd> dt nt!_eprocess poi(PsInitialSystemProcess)
[...]
   +0x094 UniqueProcessId  : 0x00000004 Void
[...]
   +0x0d8 Token            : _EX_FAST_REF
[...]
   +0x164 ImageFileName    : [16]  "System"
[...]

Référence au token de sécurité par structure ‘ex_fast_ref’

lkd> dt nt!_ex_fast_ref poi(PsInitialSystemProcess)+0x0d8
   +0x000 Object           : 0xe100075d Void
   +0x000 RefCnt           : 0y101
   +0x000 Value            : 0xe100075d

Jeton de sécurité du processus (avec application du masque sur le compteur)

  • En x86, masque de 3 bits : dt nt!_token -r1 @@(0xe100075d & ~7)
  • En x64, masque de 4 bits : dt nt!_token -r1 @@(0xfffff8a000004048 & ~15)
lkd> dt nt!_token -r1 @@(0xe100075d & ~7)
   +0x000 TokenSource      : _TOKEN_SOURCE
      +0x000 SourceName       : [8]  "*SYSTEM*"
      +0x008 SourceIdentifier : _LUID
   +0x010 TokenId          : _LUID
      +0x000 LowPart          : 0x3ea
      +0x004 HighPart         : 0n0
   +0x018 AuthenticationId : _LUID
      +0x000 LowPart          : 0x3e7
      +0x004 HighPart         : 0n0
   +0x020 ParentTokenId    : _LUID
      +0x000 LowPart          : 0
      +0x004 HighPart         : 0n0
[...]
   +0x040 ModifiedId       : _LUID
      +0x000 LowPart          : 0x3e9
      +0x004 HighPart         : 0n0
   +0x048 SessionId        : 0
[...]
   +0x080 TokenType        : 1 ( TokenPrimary )
   +0x084 ImpersonationLevel : 0 ( SecurityAnonymous )
   +0x088 TokenFlags       : 0x89 ''
   +0x089 TokenInUse       : 0 ''
[...]