format string 2
This commit is contained in:
35
format_string_2/vuln.c
Normal file
35
format_string_2/vuln.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int sus = 0x21737573;
|
||||
|
||||
int main() {
|
||||
char buf[1024];
|
||||
char flag[64];
|
||||
|
||||
|
||||
printf("You don't have what it takes. Only a true wizard could change my suspicions. What do you have to say?\n");
|
||||
fflush(stdout);
|
||||
scanf("%1024s", buf);
|
||||
printf("Here's your input: ");
|
||||
printf(buf);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (sus == 0x67616c66) {
|
||||
printf("I have NO clue how you did that, you must be a wizard. Here you go...\n");
|
||||
|
||||
// Read in the flag
|
||||
FILE *fd = fopen("flag.txt", "r");
|
||||
fgets(flag, 64, fd);
|
||||
|
||||
printf("%s", flag);
|
||||
fflush(stdout);
|
||||
}
|
||||
else {
|
||||
printf("sus = 0x%x\n", sus);
|
||||
printf("You can do better!\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user