Example #1
0
        public static void InjectShellcode(this Process process, byte[] shellcodeBuffer)
        {
            // WRITE SHELLCODE TO TARGET MEMORY
            var shellcodeRemoteCall = process.AllocateAndWrite(shellcodeBuffer, NT.AllocationType.Commit | NT.AllocationType.Reserve, NT.MemoryProtection.ExecuteReadWrite);

            // CALL THE SHELLCODE TO CALL OUR SHELLCODE
            var shellcodeThread = process.CreateThread(shellcodeRemoteCall, 0, out threadId);

            // WAIT FOR THE THREAD TO FINISH
            NTM.WaitForThread(shellcodeThread);

            // FREE THE SHELLCODE
            process.FreeMemory(shellcodeRemoteCall);
        }
Example #2
0
 public static uint CreateAndWaitForThread(this Process process, ulong startAddress, ulong argumentAddress, out ulong threadHandle)
 {
     threadHandle = NT.CreateRemoteThread(process.Handle, 0, 0, startAddress, argumentAddress, 0, out ulong threadId);
     NTM.WaitForThread(threadHandle);
     return(NTM.GetThreadExitCode(threadHandle));
 }