Skip to content

Instantly share code, notes, and snippets.

@sl4v
Created December 13, 2017 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sl4v/93c97fb534924a62fd93f573bcfced73 to your computer and use it in GitHub Desktop.
Save sl4v/93c97fb534924a62fd93f573bcfced73 to your computer and use it in GitHub Desktop.
int get_bait_code(uint8_t * trampoline_code_out, uint64_t addr) {
uint8_t trampoline_code[] =
{
0x68, 0x44, 0x33, 0x22, 0x11, // push 0x11223344
0xc7, 0x44, 0x24, 0x04, 0x88, 0x77, 0x66, 0x55, //mov dword ptr [rsp+4], 0x55667788
0xc3 //ret
};
uint32_t addr_right = (uint32_t)(addr & 0xffffffff);
uint32_t addr_left = (uint32_t)((addr & 0xffffffff00000000) >> 32);
*(uint32_t *)&trampoline_code[1] = addr_right;
*(uint32_t *)&trampoline_code[9] = addr_left;
memcpy(trampoline_code_out, trampoline_code, sizeof(trampoline_code));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment