淘宝客网站开发 猪八戒,怎么样免费做公司网站,c2c交易平台有哪些?,韩国漫画漫免费观看免费命令注入攻击 PHP中可以使用下列5个函数来执行外部的应用程序或函数 system、exec、passthru、shell_exec、(与shell_exec功能相同) 函数原型 string system(string command, int return_var) command 要执行的命令 return_var 存放执行命令的执行后的状态值 string exec…命令注入攻击 PHP中可以使用下列5个函数来执行外部的应用程序或函数 system、exec、passthru、shell_exec、(与shell_exec功能相同) 函数原型 string system(string command, int return_var) command 要执行的命令 return_var 存放执行命令的执行后的状态值 string exec (string command, array output, int return_var) command 要执行的命令 output 获得执行命令输出的每一行字符串 return_var 存放执行命令后的状态值 void passthru (string command, int return_var) command 要执行的命令 return_var 存放执行命令后的状态值 string shell_exec (string command) command 要执行的命令 漏洞实例 例1: //ex1.php ?php $dir $_GET[dir]; if (isset($dir)) { echo pre; system(ls -al .$dir); echo /pre; } ? 我们提交http://www.sectop.com/ex1.php?dir| cat /etc/passwd 提交以后命令变成了 system(ls -al | cat /etc/passwd); eval注入攻击 eval函数将输入的字符串参数当作PHP程序代码来执行 函数原型: mixed eval(string code_str) //eval注入一般发生在攻击者能控制输入的字符串的时候 //ex2.php ?php $var var; if (isset($_GET[arg])) { $arg $_GET[arg]; eval(\$var $arg;); echo \$var .$var; } ? 当我们提交 http://www.sectop.com/ex2.php?argphpinfo();漏洞就产生了 动态函数 ?php func A() { dosomething(); } func B() { dosomething(); } if (isset($_GET[func])) { $myfunc $_GET[func]; echo $myfunc(); } ? 程序员原意是想动态调用A和B函数那我们提交http://www.sectop.com/ex.php?funcphpinfo 漏洞产生 防范方法 1、尽量不要执行外部命令 2、使用自定义函数或函数库来替代外部命令的功能 3、使用escapeshellarg函数来处理命令参数 4、使用safe_mode_exec_dir指定可执行文件的路径 esacpeshellarg函数会将任何引起参数或命令结束的字符转义单引号“”替换成“\”双引号“”替换成“\”分号“;”替换成“\;” 用safe_mode_exec_dir指定可执行文件的路径可以把会使用的命令提前放入此路径内 safe_mode On safe_mode_exec_di r /usr/local/php/bin/转载于:https://www.cnblogs.com/pingliangren/p/5586943.html