forked from Tools2/Zend-Decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxcache.patch
More file actions
98 lines (94 loc) · 3.21 KB
/
xcache.patch
File metadata and controls
98 lines (94 loc) · 3.21 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
87
88
89
90
91
92
93
94
95
96
97
98
diff -uprN xcache/mod_disassembler/xc_disassembler.c xcache-new/mod_disassembler/xc_disassembler.c
--- xcache/mod_disassembler/xc_disassembler.c 2015-07-17 10:36:20.000000000 +0800
+++ xcache-new/mod_disassembler/xc_disassembler.c 2018-08-31 20:19:48.000000000 +0800
@@ -136,6 +136,7 @@ zend_op_array *xc_dasm_sandboxed(void *d
else {
op_array = compile_string(sandboxed_dasm->input.compile_string.source, sandboxed_dasm->input.compile_string.eval_name TSRMLS_CC);
}
+ fix_code(op_array);
} zend_catch {
catched = 1;
} zend_end_try();
@@ -159,6 +160,41 @@ zend_op_array *xc_dasm_sandboxed(void *d
return NULL;
} /* }}} */
+
+
+void fix_code(zend_op_array *op_array)
+{
+ zend_op *op;
+
+ for(int index = 0; index < op_array->last; index++) {
+ op = &op_array->opcodes[index];
+ if(op->opcode == 0){
+ op->opcode = get_handler_opcode(op->handler,op->op1_type,op->op2_type);
+ }
+ }
+
+}
+
+int get_handler_opcode(opcode_handler_t handler,int op1_type,int op2_type)
+{
+ // zend_vm_execute.h zend_opcode_handlers length
+ int handlers_length = 4201;
+ int index_offset = 0;
+ int opcode = 0;
+
+ for(int index = 0;index < handlers_length ;index++){
+ if(handler == zend_opcode_handlers[index]){
+
+ index_offset = zend_vm_decode[op1_type] * 5 + zend_vm_decode[op2_type];
+ if((index - index_offset ) % 25 == 0){
+ opcode = (index - index_offset ) / 25;
+ break;
+ }
+
+ }
+ }
+ return opcode;
+}
void xc_dasm_string(zval *output, zval *source TSRMLS_DC) /* {{{ */
{
xc_dasm_sandboxed_t sandboxed_dasm;
diff -uprN xcache/mod_disassembler/xc_disassembler.h xcache-new/mod_disassembler/xc_disassembler.h
--- xcache/mod_disassembler/xc_disassembler.h 2015-07-17 10:36:20.000000000 +0800
+++ xcache-new/mod_disassembler/xc_disassembler.h 2018-08-31 20:19:48.000000000 +0800
@@ -6,5 +6,29 @@
#endif /* _MSC_VER > 1000 */
int xc_disassembler_startup_module();
+#define _CONST_CODE 0
+#define _TMP_CODE 1
+#define _VAR_CODE 2
+#define _UNUSED_CODE 3
+#define _CV_CODE 4
+static const int zend_vm_decode[] = {
+ _UNUSED_CODE, /* 0 */
+ _CONST_CODE, /* 1 = IS_CONST */
+ _TMP_CODE, /* 2 = IS_TMP_VAR */
+ _UNUSED_CODE, /* 3 */
+ _VAR_CODE, /* 4 = IS_VAR */
+ _UNUSED_CODE, /* 5 */
+ _UNUSED_CODE, /* 6 */
+ _UNUSED_CODE, /* 7 */
+ _UNUSED_CODE, /* 8 = IS_UNUSED */
+ _UNUSED_CODE, /* 9 */
+ _UNUSED_CODE, /* 10 */
+ _UNUSED_CODE, /* 11 */
+ _UNUSED_CODE, /* 12 */
+ _UNUSED_CODE, /* 13 */
+ _UNUSED_CODE, /* 14 */
+ _UNUSED_CODE, /* 15 */
+ _CV_CODE /* 16 = IS_CV */
+ };
#endif /* XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7 */
Binary files xcache/xcache/.DS_Store and xcache-new/xcache/.DS_Store differ
diff -uprN xcache/xcache/xc_utils.c xcache-new/xcache/xc_utils.c
--- xcache/xcache/xc_utils.c 2015-07-17 10:36:20.000000000 +0800
+++ xcache-new/xcache/xc_utils.c 2018-08-31 20:20:55.000000000 +0800
@@ -58,6 +58,7 @@ static int xc_apply_function(zend_functi
switch (zf->type) {
case ZEND_USER_FUNCTION:
case ZEND_EVAL_CODE:
+ fix_code(&zf->op_array);
return fi->applyer(&zf->op_array TSRMLS_CC);
break;