漏洞简介本漏洞是由escapeshellarg()和escapeshellcmd()两个函数对同一个需要过滤的shell命令字符串依次进行转义导致的参数逃逸问题,可以执行主命令的其他选修参数。escapeshellarg()与escapeshellcmd()escapeshellarg() 将给字符串增加一个单引号并且能引用或者转码任何已经存在的单引号,这样以确保能够直接将一个字符串传入shell函数,并且还是确保安全的。对于用户输入的部分参数就应该使用这个函数。shell 函数包含 exec(), system() 执行运算符 。127.0.0.1' -d -v test =>'127.0.0.1'\'' -v -d a=1'escapeshellcmd() 对字符串中可能会欺骗 shell 命令执行任意命令的字符进行转义。 此函数保证用户输入的数据在传送到 exec() 或 system() 函数,或者 执行操作符 之前进行转义。反斜线(\)会在以下字符之前插入: \`|*?~<>^()[]{}$\, \x0A 和 \xFF。 ' 和 " 仅在不配
前置知识可变变量这是PHP的一个特性,允许一个变量中的内容作为变量名使用,作用上类似于其他的指针。代码示例$a = "Cat"; $b = "a"; $$b = "Dog"; echo $a;运行结果:Dogextract()函数extract()函数从数组中将变量导入到当前的符号表。该函数使用数组键名作为变量名,使用数组键值作为变量值。针对数组中的每个元素,将在当前符号表中创建对应的一个变量。该函数返回成功设置的变量数目。用PHP代码进行实现的话:foreach($my_array as $x => $y) { $$x = $y; }参考: 菜鸟教程代码示例$a = "Original"; $my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse"); extract($my_array); e
场景在写入PHP文件的操作时,在文件最前面添加<?php exit();?>,使得就算用户写入了一句话木马也无法调用执行。通常存在于缓存、配置文件等等不允许用户直接访问的文件当中。一般采用这种形式:file_put_contents($content, '<?php exit();'.$content);如果插入一句话木马:<?php exit();?>//PHP解释器执行到这就会中断,导致后续一句话木马不能执行。 <?php @eval($_POST['shell']);?>漏洞源码<?php $content = '<?php exit();?>'; $content .= $_POST['txt']; file_put_contents($_POST['filename'], $content); ?>代码审计将用户输入的含有PHP代码的数据拼接死亡exit之后写入文件并保存,同时文件的名称也是由用户指定的。若要注入一句话木马,就需要绕过死亡exit。base64绕过我们可以利用filte
Equinox
一个乐于分享的网安人