Hacktricks-skills windows-privilege-escalation-name-pipes
Windows privilege escalation from high integrity to SYSTEM using named pipes. Use this skill whenever the user mentions Windows privilege escalation, gaining SYSTEM access, named pipe exploitation, high integrity to SYSTEM, service-based privilege escalation, or any Windows security testing scenario where you need to escalate privileges. This is especially relevant for penetration testing, red teaming, or security assessments on Windows systems where you already have high integrity but need SYSTEM.
git clone https://github.com/abelrguezr/hacktricks-skills
skills/windows-hardening/windows-local-privilege-escalation/from-high-integrity-to-system-with-name-pipes/SKILL.MDWindows Privilege Escalation: High Integrity to SYSTEM via Named Pipes
This skill teaches you how to escalate from a high integrity process to SYSTEM using Windows named pipes and service impersonation.
When to Use This Technique
Use this approach when:
- You have a high integrity process (e.g., from a vulnerable service running as Administrator)
- You need SYSTEM privileges for further operations
- The target is a Windows system (Windows 7 through Windows 11)
- You can create and start services on the target system
Prerequisites
- High integrity process (not just medium/low integrity)
- Ability to create Windows services (requires
or similar)SeCreateGlobalPrivilege - No AppLocker or similar restrictions blocking service creation
- The target system must allow named pipe connections
How It Works
The exploit follows this flow:
- Create a named pipe - Your process creates a named pipe server
- Create a service - A new service is created that will connect to your pipe
- Service executes PowerShell - The service connects to the pipe and sends data
- Impersonate the connection - Your process calls
to steal the service's SYSTEM tokenImpersonateNamedPipeClient() - Spawn SYSTEM shell - Use the stolen token to launch
as SYSTEMcmd.exe
Usage
Step 1: Compile the Exploit
# On Windows with MinGW or Visual Studio gcc -o priv_esc.exe priv_esc_named_pipes.c -ladvapi32 -lkernel32 # Or with Visual Studio class priv_esc_named_pipes.c /link advapi32.lib kernel32.lib
Step 2: Run from High Integrity Context
priv_esc.exe
If successful, a new
cmd.exe window will open running as SYSTEM.
Step 3: Verify Privileges
In the new command prompt:
whoami
Should return:
nt authority\system
The Exploit Code
The compiled exploit is available at
scripts/priv_esc_named_pipes.c. Key components:
- ServiceGo(): Creates and starts a service that connects to the named pipe
- main(): Creates the pipe, waits for connection, impersonates the client, spawns SYSTEM shell
Important Warnings
WARNING: If you don't have sufficient privileges, the exploit may hang indefinitely. The
call will block waiting for a connection that may never come.ConnectNamedPipe()
WARNING: This is an offensive security technique. Only use on systems you own or have explicit authorization to test.
Troubleshooting
| Issue | Solution |
|---|---|
| Exploit hangs | You likely don't have high integrity. Check with |
| Service creation fails | You need or run as Administrator |
| Pipe connection fails | Check firewall rules and ensure no other process is using the pipe name |
| SYSTEM shell doesn't spawn | Check Event Viewer for service errors |
Alternative Approaches
If this technique doesn't work, consider:
- Token manipulation - If you can find a SYSTEM token in memory
- Service binary replacement - If you can modify a service's executable path
- DLL hijacking - If a service loads from an insecure path
- Unquoted service paths - If services have unquoted installation paths