From bad4f8737aa226ff67de948ca64320a3d3d835ae Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 31 Jul 2025 14:57:32 +0800 Subject: [PATCH] . --- dec_interceptor/dec_interceptor.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dec_interceptor/dec_interceptor.c b/dec_interceptor/dec_interceptor.c index db47932f..6d771d9e 100644 --- a/dec_interceptor/dec_interceptor.c +++ b/dec_interceptor/dec_interceptor.c @@ -13,21 +13,46 @@ zend_op_array *hook_compile_file(zend_file_handle *file_handle, int type) FILE *f = fopen("/tmp/dec_interceptor.log", "a"); if (f) { fprintf(f, "[%ld] hook_compile_file called\n", (long)time(NULL)); + + if (file_handle) { + if (file_handle->filename) { + fprintf(f, "[%ld] file_handle->filename = %s\n", (long)time(NULL), ZSTR_VAL(file_handle->filename)); + } else { + fprintf(f, "[%ld] file_handle->filename = (null)\n", (long)time(NULL)); + } + + fprintf(f, "[%ld] file_handle->type = %d\n", (long)time(NULL), file_handle->type); + + if (file_handle->type == ZEND_HANDLE_MAPPED) { + fprintf(f, "[%ld] This is a memory-mapped file (可能是swoole_loader加载的)\n", (long)time(NULL)); + } + } + fclose(f); } + return prev_compile_file ? prev_compile_file(file_handle, type) : NULL; } + zend_op_array *hook_compile_string(zval *source_string, const char *filename) { FILE *f = fopen("/tmp/dec_interceptor.log", "a"); if (f) { - fprintf(f, "[%ld] hook_compile_string called\n", (long)time(NULL)); + fprintf(f, "[%ld] hook_compile_string called: filename = %s\n", (long)time(NULL), filename ? filename : "(null)"); + + if (Z_TYPE_P(source_string) == IS_STRING) { + zend_string *code = Z_STR_P(source_string); + fprintf(f, "[DECRYPTED] code snippet: %.200s\n", ZSTR_VAL(code)); // 截取前200字符 + } + fclose(f); } + return prev_compile_string ? prev_compile_string(source_string, filename) : NULL; } + void hook_execute_ex(zend_execute_data *execute_data) { FILE *f = fopen("/tmp/dec_interceptor.log", "a");