1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5
6 char global_cmpval[] = "GLOBALVARIABLE";
7
main(int argc,char ** argv)8 int main(int argc, char **argv) {
9
10 char *input = argv[1], *buf, buffer[20];
11 char cmpval[] = "LOCALVARIABLE";
12 char shortval[4] = "abc";
13
14 if (argc < 2) {
15
16 ssize_t ret = read(0, buffer, sizeof(buffer) - 1);
17 buffer[ret] = 0;
18 input = buffer;
19
20 }
21
22 if (strcmp(input, "LIBTOKENCAP") == 0)
23 printf("your string was LIBTOKENCAP\n");
24 else if (strcmp(input, "BUGMENOT") == 0)
25 printf("your string was BUGMENOT\n");
26 else if (strncmp(input, "BANANA", 3) == 0)
27 printf("your string started with BAN\n");
28 else if (strcmp(input, "APRI\0COT") == 0)
29 printf("your string was APRI\n");
30 else if (strcasecmp(input, "Kiwi") == 0)
31 printf("your string was Kiwi\n");
32 else if (strncasecmp(input, "avocado", 9) == 0)
33 printf("your string was avocado\n");
34 else if (strncasecmp(input, "Grapes", argc > 2 ? atoi(argv[2]) : 3) == 0)
35 printf("your string was a prefix of Grapes\n");
36 else if (strstr(input, "tsala") != NULL)
37 printf("your string is a fruit salad\n");
38 else if (strcmp(input, "BUFFEROVERFLOW") == 0) {
39
40 buf = (char *)malloc(16);
41 strcpy(buf, "TEST");
42 strcat(buf, input);
43 printf("This will only crash with libdislocator: %s\n", buf);
44
45 } else if (*(unsigned int *)input == 0xabadcafe)
46
47 printf("GG you eat cmp tokens for breakfast!\n");
48 else if (memcmp(cmpval, input, 8) == 0)
49 printf("local var memcmp works!\n");
50 else if (memcmp(shortval, input, 4) == 0)
51 printf("short local var memcmp works!\n");
52 else if (memcmp(global_cmpval, input, sizeof(global_cmpval)) == 0)
53 printf("global var memcmp works!\n");
54 else if (strncasecmp("-h", input, 2) == 0)
55 printf("this is not the help you are looking for\n");
56 else
57 printf("I do not know your string\n");
58
59 return 0;
60
61 }
62
63