Registry-based privilege escalation
WARNING: Modifying system registry keys can destabilize the system or introduce serious security risks. These techniques should only be used in controlled environments with full authorization and proper backups.
Registry Permission Weaknesses
Understanding the Windows Registry
The Windows Registry is essentially a giant database that stores all the settings and configurations for your Windows system. Think of it like a massive filing cabinet where Windows keeps all its important information.
How the Registry Works
The Registry Structure: The registry is organized like a folder tree, with main sections called "hives":
HKLM (HKEY_LOCAL_MACHINE) - Settings that affect the entire computer
HKCU (HKEY_CURRENT_USER) - Settings specific to the currently logged-in user
HKU (HKEY_USERS) - Settings for all user accounts on the computer
HKCR (HKEY_CLASSES_ROOT) - File associations and COM object information
HKCC (HKEY_CURRENT_CONFIG) - Hardware configuration information
Registry Keys and Values:
Keys are like folders - they contain other keys or values
Values are like files - they store actual data (text, numbers, etc.)
Data Types include strings (REG_SZ), numbers (REG_DWORD), and others
Real-World Example
Let's say you install a program called "SuperApp". Here's what happens in the registry:
Installation Entry: Windows creates
HKLM\SOFTWARE\SuperApp\Settings Storage: The app stores its settings like
InstallPath=C:\Program Files\SuperAppStartup Entry: If it starts with Windows, it adds
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\SuperApp=C:\Program Files\SuperApp\app.exe
Why Registry Permissions Matter
Every registry key has permissions just like files and folders. These permissions control:
Who can read the key and its values
Who can write new values or modify existing ones
Who can delete keys or values
Who can change permissions on the key
The Problem: Sometimes when software is installed, the permissions get set incorrectly. For example:
A key that should only be writable by administrators might be writable by regular users
Critical system settings might have overly permissive access
Application configuration keys might allow unauthorized modifications
How Registry Attacks Work Step-by-Step
Step 1: Find Writable Keys An attacker looks for registry keys they can modify but shouldn't be able to. For example, if HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run is writable by regular users, that's a problem.
Step 2: Identify Impact The attacker figures out what happens if they modify this key. In this case, anything in the "Run" key automatically starts when Windows boots.
Step 3: Exploit The attacker adds their malicious program to the Run key: MyMalware=C:\temp\backdoor.exe
Step 4: Persistence Now every time Windows starts, their backdoor automatically runs with whatever privileges the registry key grants.
Understanding the Attack
The Windows Registry is like the central control panel for your entire system. It stores critical settings for Windows, applications, and security configurations. When registry keys have weak permissions, attackers can modify these settings to gain higher privileges.
Think of it like having a master control room where someone accidentally left some doors unlocked. If you can get into those rooms, you can change important system settings that you shouldn't have access to.
Why Registry Attacks Work
Registry-based privilege escalation happens because:
Misconfigured permissions - Administrators sometimes set wrong permissions on critical keys during software installation or system configuration
System-wide impact - Registry changes affect the entire system, not just your user account
Persistent changes - Registry modifications survive reboots and system updates
Direct system control - Registry controls fundamental Windows behavior including startup, security policies, and service configurations
Note: Most critical registry modifications require administrative privileges or SYSTEM context. However, misconfigurations can sometimes allow low-privileged users to modify keys they shouldn't have access to.
Enumeration
Finding Vulnerable Registry Keys
Check critical registry locations:
Target high-value registry paths:
Test registry write access:
Using PowerUp for registry enumeration:
Using WinPEAS for comprehensive registry analysis:
Exploitation Techniques
Security Policy Modification
Disable UAC (requires Administrator privileges):
Authentication Bypass
Modify Winlogon settings (requires SYSTEM or TrustedInstaller-level access):
Security Software Bypass
Disable Windows Defender (requires SYSTEM access, may be blocked by Tamper Protection):
Auto-Run Registry Hijacking
Understanding Auto-Run Mechanisms
Windows automatically runs programs listed in specific registry locations when the system starts or a user logs in. This is like having a startup folder that Windows checks every time it boots.
Auto-run hijacking works by:
Adding malicious entries to startup locations
Modifying existing entries to include your code
Using persistent locations that survive reboots
Leveraging user or system privileges depending on the registry location
Auto-Run Registry Locations Explained
Understanding How Windows Uses Auto-Run Keys
When Windows starts up or when you log in, it doesn't just load the operating system. It also checks specific registry locations for programs it should automatically start. This is like Windows having a checklist of "things to do when starting up."
Step-by-Step Startup Process:
Windows boots up and loads core system components
Windows checks HKLM Run keys and starts those programs as SYSTEM or with elevated privileges
User logs in and Windows loads their profile
Windows checks HKCU Run keys and starts those programs as the logged-in user
Desktop appears with all auto-start programs running
Registry Key Hierarchy and Permissions
System-Wide Keys (HKLM) - Require Administrative Access:
These keys affect ALL users on the computer:
User-Specific Keys (HKCU) - Standard User Access:
These keys only affect the current user:
How Auto-Run Hijacking Works Step-by-Step
Scenario: User-Level Persistence
Let's say you're a regular user and you find you can write to HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run:
Step 1: Current State
Step 2: Add Malicious Entry
Step 3: New State
Step 4: What Happens Next
Next time you log in, Windows reads this registry key
Windows automatically starts Skype, Adobe Updater, AND your backdoor
Your backdoor now runs every time you log in
It runs with your user privileges (whatever you have access to)
Understanding Special Auto-Run Locations
Winlogon Keys - Extremely Powerful but Dangerous:
Why These Are Dangerous:
Shell modification - If your backdoor crashes, the user has no desktop
Userinit modification - If your backdoor prevents userinit from completing, user login fails
System instability - These locations are critical for Windows functionality
Real-World Auto-Run Example
Legitimate Software: When you install Skype, it adds this entry:
What an Attacker Might Do:
Find the existing entry using
reg queryBackup the original to avoid suspicion
Modify it to include their code:
Result:
Skype still starts normally (user doesn't notice anything wrong)
But the backdoor also starts silently in the background
User sees Skype working as expected
Attacker gets persistent access
Enumeration
List Current Auto-Run Entries
Basic registry queries:
Check special locations:
Using Autoruns for comprehensive auto-run analysis:
Using WinPEAS for auto-run enumeration:
Using PowerUp for auto-run checks:
Check Auto-Run Permissions
Verify write access to auto-run keys:
Exploitation Techniques
Adding New Auto-Run Entries
System-wide persistence (requires Administrator privileges):
User-level persistence (standard user access):
One-time execution:
Note: RunOnce entries execute only once after creation and are removed after execution. For ongoing persistence, use Run keys or scheduled tasks.
Hijacking Existing Entries
Backup existing entry first:
Modify existing entry with command chaining:
Advanced Persistence
Modify Winlogon Shell (requires SYSTEM or TrustedInstaller access):
Modify Userinit (requires SYSTEM or TrustedInstaller access):
User-level shell modification:
Application Configuration Tampering
Understanding Application Registry Settings
Many applications store their configuration, security settings, and privilege information in the registry. When these keys have weak permissions, you can modify application behavior to escalate privileges.
This is like finding an application's control panel and changing its security settings to work in your favor.
Common Vulnerable Patterns
Applications often store:
Security configurations - Authentication requirements, privilege settings
File paths - Executable locations, plugin directories
Update mechanisms - Server URLs, automatic update settings
Feature toggles - Admin mode switches, security feature controls
Enumeration
Finding Application Registry Keys
Using RegRipper for comprehensive registry analysis:
Using Registry Explorer for manual analysis:
Search for interesting application settings:
Check permissions on common applications:
Using Seatbelt for application enumeration:
Exploitation Techniques
Security Software Bypass
Check Windows Defender settings:
Disable Windows Defender (requires SYSTEM access, may be blocked by Tamper Protection):
Add exclusion paths:
Application Privilege Escalation
Modify application privilege settings (hypothetical example):
Hijack update mechanisms:
Quick Enumeration
PowerUp comprehensive registry check:
WinPEAS registry analysis:
Seatbelt for registry security analysis:
Autoruns for complete startup analysis:
Automated Tools
PowerUp registry checks:
WinPEAS comprehensive analysis:
Seatbelt registry enumeration:
SharpUp (C# version of PowerUp):
Last updated
Was this helpful?