Windows provides printing functionality to the user and allows the user to add port monitors for more extendibility. Port monitor is a DLL which connects the spooling service and a printer, and allows to send raw device commands to the printer. We can abuse this for persistence by adding our own arbitrary dll that acts as a "monitor" .
This will be executed as SYSTEM, and will be spawned under spoolsv.exe.
We can do this in 2 ways, via registry or via the AddMonitor function. To do this via registry: