githubEdit

Privilege Escalation


Check Permissions

cacls C:\Path\To\Check\
Permission
Meaning

F

Full control

R

Read & execute

C

Read, write, execute, & delete

W

Write


PATH Variable Hijacking

The %PATH% variable is constructed from two locations:

  • User - HKEY_CURRENT_USER\Environment (user can modify)

  • Machine - HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment (admin only)

User processes use Machine + User paths. System processes use only Machine paths.

env
cacls C:\Python313\Scripts\

If a directory in PATH is writable by standard users, you can place a malicious executable there.


Service Exploits

Search Order Hijacking

Place malicious executable where service will find it first.

Unquoted Service Paths

Exploit unquoted paths with spaces.

If you cannot start/stop the service, wait for reboot or trigger one.

Weak Service Binary Permissions

Replace the actual service executable.

Weak Service Registry Permissions

Modify service configuration via registry.


DLL Search Order Hijacking

Typical DLL search order:

  1. The executing directory

  2. The System32 directory

  3. The 16-bit System directory

  4. The Windows directory

  5. The current working directory

  6. Directories in PATH


UAC Bypass (Medium → High Integrity)

Prerequisite: Must be member of local Administrators group

Check current integrity:

elevate Command

Exploit
Description

svc-exe

Get SYSTEM via service

uac-schtasks

Bypass via SilentCleanup

uac-token-duplication

Token duplication bypass

runasadmin Command

Execute arbitrary commands with elevation.

Exploit
Description

uac-cmstplua

CMSTPLUA COM interface

uac-eventvwr

eventvwr.exe bypass

uac-schtasks

SilentCleanup bypass

uac-token-duplication

Token duplication

uac-wscript

wscript.exe bypass

CMSTPLUA UAC Bypass

Requirement: Beacon process must be in C:\Windows\*

  1. Spawn a new Beacon:

  2. Generate PowerShell one-liner:

    • Right-click Beacon → Access > One-liner

    • Select tcp-local listener

  3. Execute bypass:


Quick Reference

Vulnerability
Detection
Exploitation

PATH Hijack

Writable dir in PATH

Place malicious EXE

Search Order Hijack

Writable service directory

Place malicious DLL/EXE

Unquoted Path

Space in unquoted service path

Place EXE at path break

Weak Binary

Writable service executable

Replace EXE

Weak Registry

Writable service registry key

Modify ImagePath

DLL Hijack

Writable dir in DLL search order

Place malicious DLL

UAC Bypass

Medium integrity + local admin

elevate/runasadmin

Last updated