Skip to content

Instantly share code, notes, and snippets.

@JusticeRage
Created September 20, 2021 07:40
Show Gist options
  • Save JusticeRage/9a7c31208cda1cf086427e50f329d3e9 to your computer and use it in GitHub Desktop.
Save JusticeRage/9a7c31208cda1cf086427e50f329d3e9 to your computer and use it in GitHub Desktop.
unsigned char shellcode[] = "\xCC\x90\x90\x90\x90...";
int main(int argc, char argv)
{
auto buffer = ::VirtualAlloc(nullptr, 0x1000, MEM_COMMIT, PAGE_READWRITE);
memcpy(buffer, &shellcode, sizeof(shellcode));
DWORD ignored;
::VirtualProtect(buffer, sizeof(shellcode), PAGE_EXECUTE_READ, &ignored);
auto f = reinterpret_cast<int32_t(*)()>(buffer);
f();
::VirtualFree(buffer, 0, MEM_RELEASE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment