Skip to content

Instantly share code, notes, and snippets.

@koturn
Last active August 29, 2015 14:14
Show Gist options
  • Save koturn/5da5b1fc1f598e7ea91a to your computer and use it in GitHub Desktop.
Save koturn/5da5b1fc1f598e7ea91a to your computer and use it in GitHub Desktop.
配列プログラミング
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
static int stack[128 * 1024];
static unsigned char code[] = {
0x55, 0x56, 0x57, 0x8b, 0x74, 0x24, 0x10, 0x8b, 0x7c, 0x24, 0x14, 0x8b, 0x6c, 0x24, 0x18, 0x83,
0x45, 0x00, 0x09, 0x8b, 0x45, 0x00, 0x85, 0xc0, 0x0f, 0x84, 0x1d, 0x00, 0x00, 0x00, 0x83, 0xc5,
0x04, 0x83, 0x45, 0x00, 0x08, 0x83, 0xc5, 0x04, 0x83, 0x45, 0x00, 0x0b, 0x83, 0xc5, 0x04, 0x83,
0x45, 0x00, 0x05, 0x83, 0xed, 0x0c, 0xff, 0x4d, 0x00, 0xeb, 0xd8, 0x83, 0xc5, 0x04, 0xff, 0x75,
0x00, 0xff, 0xd6, 0x58, 0x83, 0xc5, 0x04, 0x83, 0x45, 0x00, 0x02, 0xff, 0x75, 0x00, 0xff, 0xd6,
0x58, 0x83, 0x45, 0x00, 0x07, 0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0xff, 0x75, 0x00, 0xff, 0xd6,
0x58, 0x83, 0x45, 0x00, 0x03, 0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0x83, 0xc5, 0x04, 0xff, 0x4d,
0x00, 0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0x83, 0x6d, 0x00, 0x0c, 0xff, 0x75, 0x00, 0xff, 0xd6,
0x58, 0x83, 0xed, 0x04, 0x83, 0x45, 0x00, 0x08, 0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0x83, 0x6d,
0x00, 0x08, 0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0x83, 0x45, 0x00, 0x03, 0xff, 0x75, 0x00, 0xff,
0xd6, 0x58, 0x83, 0x6d, 0x00, 0x06, 0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0x83, 0x6d, 0x00, 0x08,
0xff, 0x75, 0x00, 0xff, 0xd6, 0x58, 0x83, 0xc5, 0x04, 0xff, 0x45, 0x00, 0xff, 0x75, 0x00, 0xff,
0xd6, 0x58, 0x5f, 0x5e, 0x5d, 0xc3,
};
int
main(void)
{
DWORD old_protect;
VirtualProtect((LPVOID) code, sizeof(code), PAGE_EXECUTE_READWRITE, &old_protect);
((void (*)(int (*)(int), int (*)(), int *)) (unsigned char *) code)(putchar, getchar, stack);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
static int stack[128 * 1024];
static unsigned char code[] = {
0x56, 0x57, 0x55, 0x48, 0x89, 0xce, 0x48, 0x89, 0xd7, 0x4c, 0x89, 0xc5, 0x83, 0x45, 0x00, 0x09,
0x8b, 0x45, 0x00, 0x85, 0xc0, 0x0f, 0x84, 0x21, 0x00, 0x00, 0x00, 0x48, 0x83, 0xc5, 0x04, 0x83,
0x45, 0x00, 0x08, 0x48, 0x83, 0xc5, 0x04, 0x83, 0x45, 0x00, 0x0b, 0x48, 0x83, 0xc5, 0x04, 0x83,
0x45, 0x00, 0x05, 0x48, 0x83, 0xed, 0x0c, 0xff, 0x4d, 0x00, 0xeb, 0xd4, 0x48, 0x83, 0xc5, 0x04,
0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x48, 0x83,
0xc5, 0x04, 0x83, 0x45, 0x00, 0x02, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6,
0x48, 0x83, 0xc4, 0x20, 0x83, 0x45, 0x00, 0x07, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20,
0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6,
0x48, 0x83, 0xc4, 0x20, 0x83, 0x45, 0x00, 0x03, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20,
0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x48, 0x83, 0xc5, 0x04, 0xff, 0x4d, 0x00, 0x48, 0x8b, 0x4d,
0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x83, 0x6d, 0x00, 0x0c, 0x48,
0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x48, 0x83, 0xed,
0x04, 0x83, 0x45, 0x00, 0x08, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6, 0x48,
0x83, 0xc4, 0x20, 0x83, 0x6d, 0x00, 0x08, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff,
0xd6, 0x48, 0x83, 0xc4, 0x20, 0x83, 0x45, 0x00, 0x03, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec,
0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x83, 0x6d, 0x00, 0x06, 0x48, 0x8b, 0x4d, 0x00, 0x48,
0x83, 0xec, 0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x83, 0x6d, 0x00, 0x08, 0x48, 0x8b, 0x4d,
0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20, 0x48, 0x83, 0xc5, 0x04, 0xff,
0x45, 0x00, 0x48, 0x8b, 0x4d, 0x00, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd6, 0x48, 0x83, 0xc4, 0x20,
0x5d, 0x5f, 0x5e, 0xc3,
};
int
main(void)
{
DWORD old_protect;
VirtualProtect((LPVOID) code, sizeof(code), PAGE_EXECUTE_READWRITE, &old_protect);
((void (*)(int (*)(int), int (*)(), int *)) (unsigned char *) code)(putchar, getchar, stack);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment