forked from karthick18/inception
-
Notifications
You must be signed in to change notification settings - Fork 1
/
inception.h
115 lines (95 loc) · 4.39 KB
/
inception.h
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
105
106
107
108
109
110
111
112
113
/*
* x86 code morphing to perform inception. Find the inception!
*/
#ifndef _INCEPTION_C_
#error "This special header file has to be included only from inception.c"
#endif
/*
* Removed inception string hints from the header. The hints were in earlier commits.
*/
#ifdef __linux__
#ifdef __i386__
/*
* Uses IA32 emulation specific int 0x80 for syscalls
*/
static unsigned char inception_thoughts[] = {
0xe9, 0x1e, 0x00, 0x00, 0x00, 0x59, 0xb8, 0x04,
0x00, 0x00, 0x00, 0xbb, 0x01, 0x00, 0x00, 0x00,
0xba, 0x37, 0x00, 0x00, 0x00, 0xcd, 0x80, 0xb8,
0x01, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00,
0x00, 0xcd, 0x80, 0xe8, 0xdd, 0xff, 0xff, 0xff,
0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c,
0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6d,
0x79, 0x20, 0x66, 0x61, 0x74, 0x68, 0x65, 0x72,
0x20, 0x61, 0x6e, 0x64, 0x20, 0x68, 0x61, 0x76,
0x65, 0x20, 0x6d, 0x79, 0x20, 0x6f, 0x77, 0x6e,
0x20, 0x69, 0x6e, 0x64, 0x69, 0x76, 0x69, 0x64,
0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x0a,
};
#else /* __x86_64__ */
/*
* For 64 bit, find the inception buffer with the assembly equivalent using:
* syscall over int 0x80 for x86_64
asm(".section .text\n"
".byte 0xe9\n" // fool linker to enable relative addressing
".long 0x26\n" // relative JMP call to 0x1e or "call" instruction below
"popq %rsi\n"
"movq $"STR(__NR_write)",%rax\n"
"movq $1, %rdi\n"\
"movq $55, %rdx\n"
"syscall\n"
"movq $"STR(__NR_exit)",%rax\n"
"movl $0, %edi\n"
"syscall\n"
".byte 0xe8\n"
".long -0x2b\n"//"call -0x23\n"
".string \n");
*/
static unsigned char inception_thoughts[] = {
0xe9 ,0x26 ,0x00 ,0x00 ,0x00 ,0x5e ,0x48 ,0xc7,
0xc0 ,0x01 ,0x00 ,0x00 ,0x00 ,0x48 ,0xc7 ,0xc7,
0x01 ,0x00 ,0x00 ,0x00 ,0x48 ,0xc7 ,0xc2 ,0x37,
0x00 ,0x00 ,0x00 ,0x0f ,0x05 ,0x48 ,0xc7 ,0xc0,
0x3c ,0x00 ,0x00 ,0x00 ,0xbf ,0x00 ,0x00 ,0x00,
0x00 ,0x0f ,0x05 ,0xe8 ,0xd5 ,0xff ,0xff ,0xff,
0x52 ,0x65 ,0x63 ,0x6f ,0x6e ,0x63 ,0x69 ,0x6c,
0x65 ,0x20 ,0x77 ,0x69 ,0x74 ,0x68 ,0x20 ,0x6d,
0x79 ,0x20 ,0x66 ,0x61 ,0x74 ,0x68 ,0x65 ,0x72,
0x20 ,0x61 ,0x6e ,0x64 ,0x20 ,0x68 ,0x61 ,0x76,
0x65 ,0x20 ,0x6d ,0x79 ,0x20 ,0x6f ,0x77 ,0x6e,
0x20 ,0x69 ,0x6e ,0x64 ,0x69 ,0x76 ,0x69 ,0x64,
0x75 ,0x61 ,0x6c ,0x69 ,0x74 ,0x79 ,0x0a,
};
#endif
/*
* Fill the inception target Fischers dream buffer to return with x86 instruction NOP op-code
* This is the target buffer to be filled with the actual thoughts by the guys planting the inception in
* Fischers dream
*/
static unsigned char fischers_thoughts[] = { [ 0 ... sizeof(inception_thoughts)-1] = 0x90,
0xb8, 0x1, 0x00, 0x00,
0x00, 0xbb, 0x00, 0x00, 0x00, 0x00,0xcd, 0x80,
};
#elif defined(__APPLE__)
static unsigned char inception_thoughts[] = {
0xe9,0x24,0x00,0x00,0x00,0x59,0xb8,0x04
,0x00,0x00,0x00,0xbb,0x01,0x00,0x00,0x00
,0xba,0x37,0x00,0x00,0x00,0x52,0x51,0x53
,0x50,0xcd,0x80,0xb8,0x01,0x00,0x00,0x00
,0xbb,0x00,0x00,0x00,0x00,0x53,0x50,0xcd
,0x80,0xe8,0xd7,0xff,0xff,0xff,0x52,0x65
,0x63,0x6f,0x6e,0x63,0x69,0x6c,0x65,0x20
,0x77,0x69,0x74,0x68,0x20,0x6d,0x79,0x20
,0x66,0x61,0x74,0x68,0x65,0x72,0x20,0x61
,0x6e,0x64,0x20,0x68,0x61,0x76,0x65,0x20
,0x6d,0x79,0x20,0x6f,0x77,0x6e,0x20,0x69
,0x6e,0x64,0x69,0x76,0x69,0x64,0x75,0x61
,0x6c,0x69,0x74,0x79,0x0a
};
static unsigned char fischers_thoughts[] = { [ 0 ... sizeof(inception_thoughts)-1] = 0x90,
0xbb, 0x00, 0x00, 0x00, 0x00, 0x53, 0xb8, 0x01
,0x00, 0x00, 0x00, 0x50, 0xcd, 0x80,
};
#else
#error "Unsupported Arch. Force compilation errors"
#endif