forked from emilytouchingcomputers/CTFium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JNF.c
104 lines (82 loc) · 1.96 KB
/
JNF.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//Overflow on the heap to overwrite function pointer, then call that function
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct coordinates
{
char userinput[64];
short choice;
};
struct jmptable
{
void (*hyperJump1)();
void (*hyperJump2)();
void (*hyperJump3)();
};
void jumpToHoth()
{
printf("Jumping to Hoth...\n");
}
void jumpToCoruscant()
{
printf("Jumping to Coruscant...\n");
}
void jumpToEndor()
{
printf("Jumping to Endor...\n");
}
void jumpToNaboo()
{
printf("Jumping to Naboo...\n *Run this on the server to get the flag. *\n");
}
int main() {
char* ptr;
struct coordinates* ptr1;
struct jmptable* ptr2;
ptr1 = malloc(sizeof(struct coordinates));
ptr2 = malloc(sizeof(struct jmptable));
ptr2->hyperJump1 = &jumpToHoth;
ptr2->hyperJump2 = &jumpToCoruscant;
ptr2->hyperJump3 = &jumpToEndor;
while(1)
{
printf("SYSTEM CONSOLE> ");
gets(ptr1->userinput);
ptr1->choice = strtol(ptr1->userinput, &ptr, 10);
switch( (int)ptr1->choice)
{
case 1:
{
printf("Checking navigation...\n");
ptr2->hyperJump1();
break;
}
case 2:
{
printf("Checking navigation...\n");
ptr2->hyperJump2();
break;
}
case 3:
{
printf("Checking navigation...\n");
ptr2->hyperJump3();
break;
}
case 4:
{
printf("Logging out\n");
exit(0);
}
default:
{
printf("Check Systems\n");
printf("1 - Hoth\n");
printf("2 - Coruscant\n");
printf("3 - Endor\n");
printf("4 - Logout\n");
}
}
}
return 0;
}