防护建议
- 禁用所有不必要的执行函数
- 使用Web应用防火墙(WAF)
- 实施严格的输入验证和过滤
- 定期更新和修补系统
- 使用最小权限原则运行Web服务器
危险的php函数
<?php
// 1. system()函数
system('whoami');// 2. exec()函数
exec('ls -la', $output);
print_r($output);// 3. passthru()函数
passthru('pwd');// 4. popen()函数
$handle = popen('cat /etc/passwd', 'r');
echo fread($handle, 2096);
pclose($handle);// 5. proc_open()函数
$descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
$process = proc_open('id', $descriptors, $pipes);
echo stream_get_contents($pipes[1]);
proc_close($process);
?>// 6.shell_exec()函数