blob: 2902377e25265c6b29026c9bd3a87da015f7b9f2 (
plain)
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
|
#include "php_snuffleupagus.h"
ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus);
static zend_op_array *(*orig_compile_file)(zend_file_handle *, int);
static zend_op_array *(*orig_compile_string)(zval *, char *);
zend_op_array *sp_compile_file(zend_file_handle *file_handle, int type) {
zend_op_array *ret = orig_compile_file(file_handle, type);
const sp_node_t* config = SNUFFLEUPAGUS_G(config).config_disabled_functions->disabled_functions;
while (config && config->data) {
const char* function_name = ((sp_disabled_function*)config->data)->function;
const pcre* function_name_regexp = ((sp_disabled_function*)config->data)->r_function;
sp_log_err("checking for %s", function_name);
// EG(function_table)->arData[count - 1].val.value.func->internal_function.handler = PHP_FN(check_disabled_function);
if (function_name) {
if (HOOK_FUNCTION(function_name, disabled_functions_hook, PHP_FN(check_disabled_function), true) == SUCCESS) {
sp_log_err("Successfully hooked %s", function_name);
}
break;
} else if (function_name_regexp) {
sp_log_err("error", "We'll hook regard later.");
}
config = config->next;
}
return ret;
}
zend_op_array *sp_compile_string(zval *source_string, char *filename) {
zend_op_array *ret = orig_compile_string(source_string, filename);
sp_log_err("in compile_string : filename is :%s", filename);
return ret;
}
int hook_compile(void) {
TSRMLS_FETCH();
/* zend_compile_file is used to compile php file */
orig_compile_file = zend_compile_file;
zend_compile_file = sp_compile_file;
/* zend_compile_string is used to compile php string */
orig_compile_string = zend_compile_string;
zend_compile_string = sp_compile_string;
return SUCCESS;
}
|