Hijacking to Shellcode

Lecture

Hijacking to Shellcode

Example from the Shellcoding Module

void bye1() { puts("Goodbye!"); }
void bye2() { puts("Farewell!"); }
void hello(char *name, void (*bye_func)())
{
    printf("Hello %s!\n", name);
    bye_func();
}
int main(int argc, char **argv)
{
    char name[1024];
    gets(name);
    srand(time(0));
    if (rand() % 2) hello(bye1, name);
    else hello(name, bye2);
}
  • Bug 1: hello(bye1, name) should be hello(name, bye1).

  • Bug 2: gets(name) causes buffer overflow.

Last updated