Home  >  Article  >  Backend Development  >  Detailed explanation of PHP dangerous functions_PHP tutorial

Detailed explanation of PHP dangerous functions_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:231046browse

在编译 PHP 时,如无特殊需要,一定禁止编译生成 CLI 命令行模式的 PHP 解析支持。可在编译时使用 –disable-CLI。一旦编译生成 CLI 模式的PHP,则可能会被入侵者利用该程序建立一个WEB Shell 后门进程或通过PHP 执行任意代码。

phpinfo()

功能描述:输出 PHP 环境信息以及相关的模块、WEB 环境等信息。

危险等级:中

passthru()

功能描述:允许执行一个外部程序并回显输出,类似于 exec()。

危险等级:高

exec()

功能描述:允许执行一个外部程序(如 UNIX Shell 或 CMD 命令等)。

危险等级:高

system()

功能描述:允许执行一个外部程序并回显输出,类似于 passthru()。

危险等级:高

chroot()

功能描述:可改变当前 PHP 进程的工作根目录,仅当系统支持 CLI 模式PHP 时才能工作,且该函数不适用于 Windows 系统。

危险等级:高

scandir()

功能描述:列出指定路径中的文件和目录。

危险等级:中

chgrp()

功能描述:改变文件或目录所属的用户组。

危险等级:高

chown()

功能描述:改变文件或目录的所有者。

危险等级:高

shell_exec()

功能描述:通过 Shell 执行命令,并将执行结果作为字符串返回。

危险等级:高

proc_open()

功能描述:执行一个命令并打开文件指针用于读取以及写入。

危险等级:高

proc_get_status()

功能描述:获取使用 proc_open() 所打开进程的信息。

危险等级:高

error_log()

功能描述:将错误信息发送到指定位置(文件)。

安全备注:在某些版本的 PHP 中,可使用 error_log() 绕过 PHP safe mode,
执行任意命令。

危险等级:低

ini_alter()

功能描述:是 ini_set() 函数的一个别名函数,功能与 ini_set() 相同。具体参见 ini_set()。

危险等级:高

ini_set()

功能描述:可用于修改、设置 PHP 环境配置参数。

危险等级:高

ini_restore()

功能描述:可用于恢复 PHP 环境配置参数到其初始值。

危险等级:高

dl()

功能描述:在 PHP 进行运行过程当中(而非启动时)加载一个 PHP 外部模块。

危险等级:高

pfsockopen()

功能描述:建立一个 Internet 或 UNIX 域的 socket 持久连接。

危险等级:高

syslog()

功能描述:可调用 UNIX 系统的系统层 syslog() 函数。

危险等级:中

readlink()

功能描述:返回符号连接指向的目标文件内容。

危险等级:中

symlink()

功能描述:在 UNIX 系统中建立一个符号链接。

危险等级:高

popen()

功能描述:可通过 popen() 的参数传递一条命令,并对 popen() 所打开的文件进行执行。

危险等级:高

stream_socket_server()

功能描述:建立一个 Internet 或 UNIX 服务器连接。

危险等级:中

putenv()

Function description: Used to change the system character set environment when PHP is running. In PHP versions earlier than 5.2.6, you can use this function to modify the system character set environment, and then use the sendmail command to send special parameters to execute the system SHELL command.

Danger Level: High

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486229.htmlTechArticleWhen compiling PHP, if there is no special need, it must be prohibited to compile and generate PHP parsing support for CLI command line mode. Can be compiled using --disable-CLI. Once compiled to generate CLI mode P...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn