认识PHP危险函数

什么是危险函数?

函数设计出来就是让人使用的,之所以危险,是因为其功能过于强大开发人员特别是刚从业的人员很少会完整阅读完整个文档,再或者是没有意识到当给这些函数传递一些非常规的,外部可控的参数会带来什么影响。
image.png
image.png

执行任意代码的函数

常见执行任意代码的函数

  1. eval函数
  2. assert函数
  3. create_function函数
  4. preg_replace函数
  5. call_user_func/call_user_func_array函数
  6. array_map函数
  7. array_filter函数
  8. usort/uasort函数
  9. $a($b)动态函数

读取网络资源的函数

  • Fopen()
  • File_get_content()
  • curl

image.pngimage.png
image.png

操作文件的函数

  1. copy()
  2. File_get_contents()/File_put_contents()
  3. File()
  4. Fopen()
  5. Move_uploaded_file()
  6. rename()
  7. rmdir()
  8. unlink()
  1. <?php
  2. copy('shell.php','shell2.php');
  3. File_get_contents('shell.php','shell2.php');
  4. File_put_contents('shell.php','shell2.php');
  5. move_uploaded_file(filename,destination);
  6. rename("旧文件","新文件名");
  7. rmdir('旧文件夹名','新文件夹名');
  8. unlink('文件名');// 删除文件
  9. ?>

改变上下文环境的函数

image.png