-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathw2_reverse-ex.c
More file actions
86 lines (68 loc) · 1.09 KB
/
Copy pathw2_reverse-ex.c
File metadata and controls
86 lines (68 loc) · 1.09 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#define KEY "KFFSE_XHKYOKXOHOFEDM^E_Y"
int
checkkey(char *key)
{
char *p = key;
for (; *p; p++)
*p ^= 42;
if (!strcmp(key,KEY))
return 1;
return 0;
}
int
foo(char *data)
{
printf("foo\n");
return 0;
}
int
bar(char *data)
{
printf("bar\n");
return 0;
}
int
foobar(char *data)
{
foo(data);
return 0;
}
int
main(void)
{
char buf[512];
int n, ret;
int (*f)(char *);
//memset(buf, 0, sizeof(buf));
printf("Are you feeling lucky today? ");
fflush(stdout);
(void)read(0, buf, sizeof(buf)-1);
n = strlen(buf);
if (buf[n-1] == '\n')
buf[n-1] = 0;
switch (buf[0]) {
case 0x41:
f = &foo;
break;
case 0x42:
f = &checkkey;
break;
case 0x43:
f = &foobar;
break;
default:
loop:
goto *&&loop;
}
ret = f(buf+1);
if (ret)
printf("[+] WooT!: %s\n", buf+1);
else
printf("[-] Nope.\n");
exit(ret);
}