Created
December 10, 2013 14:17
-
-
Save kaworu/7891248 to your computer and use it in GitHub Desktop.
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> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
void target(void) __attribute__ ((section (".attack"))); | |
void target(void) { | |
system("/bin/cat secret"); | |
} | |
void vuln(char *arg) { | |
char len = 0; | |
char hello[108] = "Hello, "; | |
len = strlen(arg); | |
if (len > 100) { | |
printf("Sorry, name too long !\n"); | |
exit(1); | |
} | |
strcat(hello, arg); | |
printf("%s.\n",hello); | |
} | |
int main(int argc, char **argv) { | |
setregid(getegid(), getegid()); | |
printf("Hint: %p\n", target); | |
if (argc != 2) { | |
printf("Usage: ./program2 <argument>\n"); | |
exit(2); | |
} | |
vuln(argv[1]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment