Shellcode Execution in a Local Process with QueueUserAPC and NtTestAlert
This is a quick lab that shows how to execute shellcode within a local process by leveraging a Win32 API QueueUserAPC and an officially undocumented Native API NtTestAlert, which lands in kernel that calls KiUserApcDispatcher if the APC queue is not empty.
The advantage of this technique is that it does not rely on CreateThread or CreateRemoteThread API calls which are more popular and hence usually more scrutinized by SOCs and AV/EDR vendors.
Thanks to Mumbai for pointing me to NtTestAlert.
Execution
The flow of the technique is simple:
Allocate memory in the local process for the shellcode
Write shellcode to the newly allocated memory location