At boot
Port Monitors and Print Processors: Spooler Persistence
How port monitor and print processor DLLs give SYSTEM persistence inside the Print Spooler, how attackers register them, and how to find and remove them.
- Tactics
- Persistence, Privilege escalation
- Runs
- At boot
- Set up by
- Administrators
- Locations
- HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors
- HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Print Processors
- C:\Windows\System32
- C:\Windows\System32\spool\prtprocs\x64
How it works
The Print Spooler service (Spooler, spoolsv.exe) runs as SYSTEM and starts automatically at boot on Windows 10 and 11. When it starts, it loads two kinds of plug-in DLLs listed in the SYSTEM hive, and keeps them loaded for as long as it runs.
Port monitors move print jobs to a port: a local port, a TCP/IP printer, USB, WSD. The spooler loads every monitor at start-up and calls its InitializePrintMonitor2 export. Software registers one with the AddMonitor API; Microsoft's documentation says the caller needs SeLoadDriverPrivilege and the monitor's files must be in System32. Writing the registry directly works too, and then the Driver value can hold a full path. ATT&CK tracks this as T1547.010.
Print processors turn a job into something the printer understands. Windows' own, winprint, handles the RAW, EMF and TEXT data types. Software registers one with AddPrintProcessor, and the DLL must sit in the print processor directory returned by GetPrintProcessorDirectory: C:\Windows\System32\spool\prtprocs\x64 on 64-bit Windows. ATT&CK tracks this as T1547.012.
Either way the code runs inside spoolsv.exe as SYSTEM, from every boot, with no process of its own. A malicious DLL usually starts its payload on a thread and returns success, so printing keeps working. An administrator can also restart the spooler to load a new DLL without rebooting.
After the PrintNightmare vulnerabilities of 2021, many organisations disabled the Print Spooler on servers and domain controllers. Where the Spooler service has Start set to 4 (disabled), nothing in these keys is loaded.
Where it lives
| Key | Driver on stock Windows 10 and 11 |
|---|---|
HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Appmon | AppMon.dll |
...\Print\Monitors\Local Port | localspl.dll |
...\Print\Monitors\Microsoft Shared Fax Monitor | FXSMON.DLL, where fax support is installed |
...\Print\Monitors\Standard TCP/IP Port | tcpmon.dll |
...\Print\Monitors\USB Monitor | usbmon.dll |
...\Print\Monitors\WSD Port | WSDMon.dll |
HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Print Processors\winprint | winprint.dll |
A monitor's Driver is a file name resolved in System32, or a full path. A processor's Driver is a file name resolved in the processor directory of its environment. Other environments (Windows NT x86, Windows ARM64) have their own Print Processors subkeys. Printer drivers from vendors often add a processor or a monitor of their own, so compare with the printers actually installed.
Only administrators and SYSTEM can write these keys, System32 and spool\prtprocs. There is no per-user variant.
How attackers use it
A port monitor. Copy the DLL to System32, add a monitor key, and restart the spooler or wait for the next boot:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Port Helper" /v Driver /t REG_SZ /d porthlp.dll /f
Code with SeLoadDriverPrivilege can call AddMonitor instead, which writes the same key through the spooler. MITRE's page for this sub-technique cites Brady Bloxham's 2014 DEF CON talk and lists no procedure examples.
A print processor. Copy the DLL to C:\Windows\System32\spool\prtprocs\x64 and add a key under Environments\Windows x64\Print Processors with a Driver value. ESET documented PipeMon, a Winnti Group backdoor, installing itself as a print processor in 2020; MITRE ATT&CK also lists Gelsemium and Earth Lusca for this sub-technique.
Disguises: names that read like Windows' monitors (Standard TCP/IP Port 2, Microsoft Print Monitor), DLL names one letter away from real ones (tcpmon32.dll, winprnt.dll), and copied timestamps. A processor does not need to be assigned to any printer to be loaded.
How to check a host
On a live machine, from an elevated prompt:
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors" /s /v Driver
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Print Processors" /s
dir /a C:\Windows\System32\spool\prtprocs\x64
sc qc Spooler
Get-Printer | Select-Object Name, DriverName, PortName, PrintProcessor
(Get-Process spoolsv).Modules | Select-Object FileName, Company
Get-AuthenticodeSignature C:\Windows\System32\porthlp.dll
Autoruns shows monitors on its Print Monitors tab. Every DLL loaded in spoolsv.exe should be Microsoft's or belong to an installed printer driver.
Offline, read Control\Print\Monitors and Control\Print\Environments in the current control set of the SYSTEM hive (Select\Current names it). A monitor or processor key created by an attacker has the creation time as its last-write time; stock keys date from installation or a feature update. Check the DLLs' creation times in System32 and spool\prtprocs\x64.
Telemetry worth querying: Sysmon event 7 for spoolsv.exe loading a DLL not signed by Microsoft, event 11 for a DLL written into spool\prtprocs, event 13 for a new Driver value, and Security log 4657 when auditing is set on the Print key.
Suspicious: a monitor or processor no installed printer explains, a DLL without a valid signature, a Driver with a full path outside System32, and a spooler running on a server that never prints.
What Windows Persistence flags
parsePrintMonitors reads every subkey of Control\Print\Monitors and of each environment's Print Processors in the current control set, and lists one entry per Driver value, as firing at boot, with the kind (port monitor or print processor) in the details.
The six stock monitors are recognised by name and DLL together, and winprint with winprint.dll; they are marked as Windows defaults and "Hide Windows entries" hides them unless something else flags them. Anything else raises:
- Unknown print port monitor (high).
- Non-Windows print processor (medium), since printer drivers add legitimate ones.
The path rules run on the DLL: System-wide autostart from a writable folder, Runs from a temporary or public folder, Windows program name in the wrong place, Name one letter away from a Windows program, Machine-made name and Runs from a network share. Cross-checks add Written date (the key changed in the 7 days before the newest time seen on that host), Inside a Defender exclusion (exclusion) and program also runs from mechanisms for DLLs outside Windows' folders.
Limits: the default check compares names, not file contents, so a stock monitor whose DLL was replaced on disk passes. A monitor's bare file name is resolved in System32, and a processor's in System32\spool\prtprocs\ under the environment's Directory value (or x64, w32x86 or arm64 from its name), where the spooler loads it. The tool does not read print providers (Control\Print\Providers), which printers use which processor, or whether the Spooler service is disabled, in which case none of these DLLs load.
Cleaning up
- Preserve:
reg export "HKLM\SYSTEM\CurrentControlSet\Control\Print" print.reg, then copy the DLL with its timestamps and hash it. - Stop the spooler:
Stop-Service Spooler -Force. - For a monitor, delete its subkey under
Monitors. For a processor, first switch any printer that uses it back towinprint(printer properties, Advanced, Print Processor), then delete its key underPrint Processors. - Start the spooler again and delete the DLL; it was locked while the spooler had it loaded.
- Never delete the stock monitors: without
Local PortorStandard TCP/IP Port, printing breaks. - The DLL ran as SYSTEM: look for what it did next, such as other persistence, new accounts or credential theft. Reset credentials that were exposed on the machine.
- If the machine does not print, disable the spooler (
Set-Service Spooler -StartupType Disabled), which removes this class of persistence altogether.
See also
Related techniques
On Windows Forensics
The artifacts behind this technique, in the Windows Forensics reference: