Skip to content

Winlogon Helper: Userinit and Shell Persistence

How the Winlogon Userinit and Shell values start programs at every Windows logon, how attackers append to them or replace the shell, and how to restore them.

MITRE ATT&CK
T1547.004
Tactics
Persistence, Privilege escalation
Runs
At logon
Set up by
Users and administrators
Locations
  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  • HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System
  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify
  • C:\Windows\System32\userinit.exe

How it works

winlogon.exe manages interactive logons, at the console and over Remote Desktop. Once a user is authenticated, Winlogon reads HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon and starts, in the user's session and as that user, every program listed in Userinit. The list is comma-separated and its default is C:\Windows\system32\userinit.exe, with a trailing comma. userinit.exe runs the user's logon scripts, restores network connections, starts the shell named in Shell (default explorer.exe) and exits. That is why explorer.exe normally shows no running parent.

Userinit and Shell run something at every interactive logon of every user, which is what makes them useful to an attacker. The values that matter:

ValueDefaultRole
UserinitC:\Windows\system32\userinit.exe,Winlogon starts each program in the list at logon
Shellexplorer.exeUserinit starts it as the desktop shell
AutoRestartShell1The shell is restarted when it exits
VMAppletSystemPropertiesPerformance.exe /pagefileWindows' own value; treat a change like one to Userinit
Taskman, AppSetup, GinaDLL, SystemNot set on a current WindowsName a program or DLL; GinaDLL is ignored since Vista

Shell also has two per-user forms. A Shell value in HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon replaces the shell for that user only, and HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell is where the Group Policy setting "Custom User Interface" puts its shell. Kiosk and thin-client builds use these on purpose.

Older versions had two more hooks that no longer work. Windows XP and Server 2003 loaded "notification packages", DLLs listed under Winlogon\Notify\<name>\DllName, into winlogon.exe itself, as SYSTEM, and called them on logon, logoff and lock events. GinaDLL replaced the logon dialog's msgina.dll. Windows Vista removed both in favour of credential providers. They still matter on legacy systems and in old images.

Winlogon's key also holds SpecialAccounts\UserList, used to hide accounts from the sign-in screen (see local accounts), and the autologon values AutoAdminLogon, DefaultUserName and DefaultPassword, the last of which stores a password in clear text when autologon is configured that way.

Where it lives

LocationWho can write itOn a stock Windows 10 or 11
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinlogonAdministrators, SYSTEMUserinit, Shell, VMApplet at their defaults
HKCU\Software\Microsoft\Windows NT\CurrentVersion\WinlogonThe userNo Shell value
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\SystemGroup PolicyNo Shell value
HKLM\...\Winlogon\Notify\* (XP and 2003)Administrators, SYSTEMNot used since Vista
C:\Windows\System32\userinit.exeTrustedInstallerSigned by Microsoft

The per-user Shell is the only form a standard user can set for themselves. Every other form needs administrator rights and then affects every user who logs on.

How attackers use it

Appending to Userinit keeps the logon working while adding a program, so the user sees nothing (run as administrator):

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit /t REG_SZ /d "C:\Windows\system32\userinit.exe,C:\ProgramData\Microsoft\Network\netupd.exe," /f

Replacing the per-user shell needs no privileges. The payload must start explorer.exe itself, or the user gets a black screen and calls the help desk:

reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d "C:\Users\alice\AppData\Roaming\Microsoft\shellhost.exe" /f

MITRE ATT&CK records Turla adding a Shell value under that per-user key. Other variants seen in the wild change the machine Shell to explorer.exe followed by a second program, or give the added program a name that reads like a Windows one at a glance (userinlt.exe, explorer.exe in a user folder). On XP-era systems, a Notify package loaded a DLL into winlogon.exe as SYSTEM.

Because Winlogon starts these programs for Remote Desktop logons too, a modified Userinit on a server runs in the session of every administrator who connects.

How to check a host

On a live machine:

reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell
reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit
reg query "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v Shell
autorunsc.exe -accepteula -a w -s -h -c
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' | Select-Object Userinit, Shell, VMApplet, Taskman, AppSetup, GinaDLL, System
Get-ItemProperty 'Registry::HKEY_USERS\*\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name Shell -ErrorAction SilentlyContinue

Compare against the defaults character for character: C:\Windows\system32\userinit.exe, and explorer.exe. Anything after the comma in Userinit, any path in Shell, and any per-user Shell needs an explanation.

Offline, read Microsoft\Windows NT\CurrentVersion\Winlogon in the SOFTWARE hive and Software\Microsoft\Windows NT\CurrentVersion\Winlogon and Software\Microsoft\Windows\CurrentVersion\Policies\System in each NTUSER.DAT. Windows writes other values in the Winlogon key, so its last-write time is a weak clue on its own. Process creation events help more: Winlogon starts a short list of Windows programs (userinit.exe, LogonUI.exe, dwm.exe, fontdrvhost.exe…), so any other child of winlogon.exe at logon (event 4688 with command lines, or Sysmon event 1), or an explorer.exe that is not started by userinit.exe, is worth a look. Sysmon event 13 records the value change itself.

What Windows Persistence flags

The tool reads the Userinit, Shell, Taskman, AppSetup, GinaDLL, System and VMApplet values in the Winlogon key of the SOFTWARE hive, in its WOW6432Node copy and in every user hive of the collection, the Shell value of each user's Policies\System key, and the DllName of every Notify subkey.

  • Userinit equal to C:\Windows\system32\userinit.exe, (case ignored; the folder, the .exe and the trailing comma optional) is marked as the Windows default. Anything else raises Differs from the Windows default (C:\Windows\system32\userinit.exe,) (high).
  • A machine Shell of exactly explorer.exe is the default; anything else, even a full path to Explorer, raises Differs from the Windows default (explorer.exe) (high).
  • A non-empty Shell in a user's Winlogon key, or any Shell in Policies\System, raises Per-user shell replacement (high).
  • VMApplet other than SystemPropertiesPerformance.exe /pagefile raises Differs from the Windows default (SystemPropertiesPerformance.exe /pagefile) (medium).
  • A non-empty System, Taskman or GinaDLL value raises Extra Winlogon value: System (or Taskman, GinaDLL), high; AppSetup raises the same flag at medium.
  • A Notify package that matches one of Windows XP and Server 2003's own by name and DLL (crypt32chain with crypt32.dll; cryptnet, cscdll, dimsntfy and sclgntfy with the DLL of the same name; sccertprop, schedule, senslogn, termsrv and wlballoon with wlnotify.dll) is marked as the Windows default. Any other raises Winlogon notification package (medium).

Each value is split on commas and the command-line rules run on every program in it: Windows program name in the wrong place, Name one letter away from a Windows program, Runs from a temporary or public folder, Runs from a network share, Encoded PowerShell command and the others. Machine values are judged as machine-wide, so they can also raise System-wide autostart from a writable folder; per-user values are judged as the user's, where a program in the profile is normal. The entry's program is the first one in the list that is not userinit.exe or explorer.exe, so a program appended to Userinit or Shell is what the cross-checks see: Written date (the key changed in the 7 days before the newest time collected from that host), Inside a Defender exclusion (exclusion) and program also runs from mechanisms.

With Hide Windows entries on, Userinit, Shell and VMApplet at their defaults, and Windows' own Notify packages, are hidden. Anything flagged stays visible.

Limits: GPExtensions, credential providers and the autologon values are not read. The tool does not check that userinit.exe itself is Microsoft's file.

Cleaning up

  1. Preserve: reg export "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" winlogon.reg, plus the per-user key, and copy and hash the added program.
  2. Restore the value rather than delete it: reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit /t REG_SZ /d "C:\Windows\system32\userinit.exe," /f and reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d explorer.exe /f. A missing or wrong Userinit logs every user off right after logon; if that happens, fix the SOFTWARE hive offline from the recovery environment.
  3. Remove a per-user shell: reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /f, or fix the Group Policy that sets Policies\System\Shell.
  4. Delete the program, then check the other mechanisms for it (Run keys, logon scripts). Check userinit.exe and explorer.exe themselves with sfc /verifyfile=C:\Windows\System32\userinit.exe and sfc /verifyfile=C:\Windows\explorer.exe.
  5. Everyone who logged on while the change was in place ran the program in their session: rotate those users' passwords, administrators first, and look at the LSA packages and network providers, which an attacker with the same rights may have used to collect them.

See also

On Windows Forensics

The artifacts behind this technique, in the Windows Forensics reference: