#include #include #include #include #include "dump_stack.h" /* * Goal: Get the program to run this function. */ void shell(void) { execl("/bin/sh", "sh", NULL); } void vuln(char *str) { char buf[64]; strcpy(buf, str); dump_stack((void **) buf, 21, (void **) &str); } int main(int argc, char **argv) { if (argc != 2) { printf("Usage: buffer_overflow [str]\n"); return 1; } uid_t euid = geteuid(); setresuid(euid, euid, euid); printf("shell function = %p\n", shell); vuln(argv[1]); return 0; }