"Fever Dream" - Code executing when the Windows machine is locked
This code is called "Fever Dream" because I write it when I had a fever of 102.8f (39.3c) from the Influenza virus. I got tired of laying in bed non-stop. I tried to be at least a little productive.
This is a simple proof-of-concept demonstrating using WTSRegisterSessionNotification to receive message notifications when the machine is locked and unlocked from the user.
In this particular example, when the machine is locked the code checks for the existence of a thread (or it's current execution state) by invoking GetExitCodeThread. If GetExitCodeThread returns STILL_ACTIVE, thread execution resumes. Otherwise, the thread is created (presumably for the first time).
The thread called "WtsSessionLockedThread" is where the payload would go. My code here is filler — an infinite loop that invokes Sleep for 100 milliseconds.
When the machine receives an unlock message the code checks the current status of the thread (STILL_ACTIVE). If it's still active, it suspends execution.
I plan on expanding the code base, I want to try to get "lower" and making use of NTDLL and WIN32U functionality. Nothing special, but an interesting trick and maybe a neat anti-debug technique.