前言

在打轩辕杯的时候遇到这个函数且被过滤了一堆常见函数。

call_user_func

把第一个参数作为回调函数调用

1
call_user_func(callable $callback, mixed ...$args)

参数

  • callback

    将被调用的回调函数(callable,回调函数是指可以作为参数传递给其他函数或方法的函数,回调函数不止可以是简单函数,还可以是对象的方法,包括静态类方法。除了语言结构例如:array,echo,empty,eval,exit,isset,list,print 或 unset)

  • args

    0个或以上的参数,被传入回调函数。

在实战中

过滤了一堆函数

1
2
3
4
5
6
7
8
9
10
$disable_fun = array(
"exec", "shell_exec", "system", "passthru", "proc_open", "show_source",
"phpinfo", "popen", "dl", "proc_terminate", "touch", "escapeshellcmd",
"escapeshellarg", "assert", "substr_replace", "call_user_func_array",
"call_user_func", "array_filter", "array_walk", "array_map",
"register_shutdown_function", "register_tick_function", "filter_var",
"filter_var_array", "uasort", "uksort", "array_reduce", "array_walk",
"array_walk_recursive", "pcntl_exec", "fopen", "fwrite",
"file_put_contents", "readfile", "file_get_contents", "highlight_file", "eval"
);

1.尝试readgzfile

核心功能

gz文件:直接读取 .gz 文件并解压内容,无需手动处理压缩数据,并输出。

非压缩文件:如果文件不是 gzip 格式,会直接读取原内容,并输出。

那么我们就可以这样call_user_func('readgzfile','/xxx')

2.命名空间:

1
call_user_func('\system','命令')

这样也是可以直接执行命令的。