Skip to content

Instantly share code, notes, and snippets.

@benwaffle
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save benwaffle/f3cb630637a0ad880d09 to your computer and use it in GitHub Desktop.

Select an option

Save benwaffle/f3cb630637a0ad880d09 to your computer and use it in GitHub Desktop.
Writing over the return address
#include <stdio.h>
void func(){
int *ret; // a local var in stack frame
ret = &ret+2; // +1 for the int* and +1 for saved ebp
*ret += 12; // ret addr += 12 (get from disassembly)
}
int main(int argc, char *argv[]) {
func();
printf("skip this\n");
printf("return here\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment