Thread-less Payload Execution
Last updated
Last updated
Avoiding the use of threads will help us minimize our artifacts as EDRs may subscribe to callbacks which can make thread creation visible at a kernel level.
For extra stealthiness, we may want to not use threads and find other ways to execute our payload.
This technique will use a function pointer to execute our payload, we will simply create a function pointer assigned to the address of our shellcode, and then proceed to call the function pointer thus calling our shellcode.
This will make our payload run in the process's main thread instead of a new thread being spawned via createthread.
callbacks are functions that are called through a function pointer. If we pass a function pointer to our shellcode to a function that a requires a callback function as it's parameter, it will then instead execute our shellcode. This can be used to pass our shellcode instead of our function pointer.
An example of this is EnumFonts
an extensive list of such functions you can abuse for shellcode execution can be found here:
Fibers allow an app to schedule its own thread of execution rather than priority based scheduling. These are basically light weightthreads, and are invisble to the kernel due to the fact that they are implemented in kernel32.
To use fibers, we must call ConvertThreadToFiber, which will convert the thread running into a running fiber. We can then make additional fibers with the CreateFiber function.
To abuse this for shellcode execution we will:
Convert the main thread into a fiber
allocate shellcode
create a new fiber that points to our shellcode
schedule the new fiber that point to our schedule
the fiber gets scheduled and our shellcode runs