This commit is contained in:
hailin 2025-07-31 14:57:32 +08:00
parent db32006e60
commit bad4f8737a
1 changed files with 26 additions and 1 deletions

View File

@ -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");