-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin.c
40 lines (33 loc) · 763 Bytes
/
win.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
// this ensures that you don't need to flush stdout when calling printf
__attribute__((constructor)) void flush_buf() {
setbuf(stdin, NULL);
setbuf(stdout, NULL);
setbuf(stderr, NULL);
}
void win() {
FILE* flag_file;
char c;
flag_file = fopen("flag.txt", "r");
if (flag_file != NULL) {
printf("Your flag is - ");
while ((c = getc(flag_file)) != EOF) {
printf("%c", c);
}
printf("\n");
}
else {
printf("Could not find flag.txt\n");
}
}
void vulnerable() {
char buffer[0x20];
printf("Enter your name: ");
scanf("%s", buffer);
}
int main() {
printf("Calling 'vulnerable'...\n");
vulnerable();
return 0;
}