I had a homework assignment asking me to call a function without calling it explicitly using a buffer overflow. The code is basically like this:
#include <stdio.h> #include <stdlib.h> void g() { printf("now inside g()!\n"); } void f() { printf("now inside f()!\n"); // can only modify this section // cant call g(), maybe use g (pointer to function) } int main (int argc, char *argv[]) { f(); return 0; }
Although I'm not sure how to proceed. I thought about changing the return address for the program counter so that it goes directly to the g () address, but I'm not sure how to access it. Anyway, the tips would be great.
c stack-trace pointers buffer-overflow fortify-source
sa125 Feb 25 2018-10-25 12:27
source share