-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathwarmup.c
59 lines (53 loc) · 1.26 KB
/
warmup.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void welcome() {
puts("");
puts(" # # #### ##### ######");
puts(" # # # # # #");
puts("### ### # # #####");
puts(" # # # # #");
puts(" # # # # # #");
puts(" #### # #");
puts("");
puts("Let's warmup now!");
return;
}
void info(int fd, char log[]) {
write(fd, log, strlen(log));
}
char *bak = NULL;
int main () {
setbuf(stdin, NULL);
setbuf(stdout, NULL);
size_t leak;
char name[8];
char *canary = NULL;
welcome();
bak = (char*)malloc(8);
canary = bak;
memset(name, 0, 8);
puts("What are you looking for?");
scanf("%zu", &leak);
printf("%#zx\n", *(size_t *)leak);
puts("What's your name?");
scanf("%s", name);
if (canary == bak) {
puts("Bye bye.");
return 0;
} else {
int fd = open("/dev/tty", O_RDWR);
if (fd != -1) {
info(fd, "[INFO] A hacker is coming!\n");
info(fd, "[INFO] Exiting...\n");
_exit(1);
} else {
puts("Something is broken!");
return 0;
}
}
}