This is a shellcode injection technique that works as follows:
Start a target process into which the shellcode will be injected, in suspended state.
Get AddressOfEntryPoint of the target process
Write shellcode to AddressOfEntryPoint retrieved in step 2
Resume target process
Catch the incoming shell
What's nice about this technique is that we do not need to allocate RWX memory pages in the victim process which some EDRs may not like.
Execution
First, in order to get AddressOfEntryPoint, we need to get the image base address of the target process - notepad.exe:
We then need to parse out the NT and Optional Headers and find the AddressEntryPoint (Relative Virtual Address) of the notepad.exe which in my case was at 0001bf90:
Knowing notepad's image base address and an RVA of the AddressEntryPoint, we can get its Virtual Address (by adding the two up) and hijack the executable by overwriting the very first instructions found at that address with our shellcode:
Resuming the suspended process executes our shellcode which results in a meterpreter session: