Last active
August 29, 2015 14:01
-
-
Save benwaffle/f3cb630637a0ad880d09 to your computer and use it in GitHub Desktop.
Writing over the return address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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