1. 代码执行函数:

    eval() assert() preg_replace() creat_function() call_user_func() call_user_func_array()

// preg_replace("/test/e","$_GET[h]","jutst test");    //?h=phpinfo()
/*
第一个参数:要搜索的模式,可以是字符串或一个字符串数组。 如果使用了/e参数,导致可以代码执行    https://www.jb51.net/article/145649.htm
第二个参数:用于替换的字符串或字符串数组。
第三个参数:要搜索替换的目标字符串或字符串数组。
搜索第一个参数,替换成第三个
*/



// $newfunc = create_function('$v','return system($v);');
// $newfunc('whoami');

// $a='sys'.'tem';
// $a('whoami');

/*
创建一个匿名函数,并返回独一无二的函数名
这是PHP的一个特性,可以把变量作为函数名执行
*/



// function test($b){
// 	echo "callback $b";
// }
// call_user_func('test','11111111111');
// call_user_func('system','whoami');
//回调函数
  1. 命令执行函数:

    exec() passthru() shell_exec() system() proc_open() popen() 管道符

  2. 包含函数:

    require() include() require_once() include_once()
    incluce 在用到时加载 引入不存文件时产生一个警告且脚本还会继续执行
    require 在一开始就加载 会导致一个致命性错误且脚本停止执行
    _once 后缀表示已加载的不加载

// include($_GET['file']);
// ?file=php://filter/read=convert.base64-encode/resource=xxx.php
// 包含图片,包含任意文件
  1. 文件操作函数:

    copy() file_get_contents() file_put_contents() file() move_uploaded_file() readfile() rename() unlink()&delete() etc.
    读取配置文件,写入shell,删除.lock文件重新安装

  2. 特殊函数:

    phpinfo()
    symlink() 对于已有的target建立一个名为link的符号链接
    getenv() putenv() dl()输入指定参数library的PHP扩展 ini_get()获取配置 is_numeric() intval() in_array() etc.

posted on 2022-09-13 18:14  noone52  阅读(14)  评论(0编辑  收藏  举报