了解命令执行函数 system() passthru() 需回显示函数exec() shell_exec() ` `反引号
不会回显函数 popen(cmd,'r') 不常用函数proc_open() pcntl_exec() pcntl是linux下的一个拓展
system()

exec()
需要打印才能回显

passthru()

shell_exec()
需要打印回显

` `反引号
需要打印回显

popen(cmd,'r')
不会有回显,但实际上已经执行成功了,需要 'r' 读取
php输出Resource id #2,这个结果表示的是输出一个记录集合

pcntl_exec()
1、说明
pcntl是linux下的一个扩展,可以支持php的多线程操作。
pcntl_exec函数的作用是在当前进程空间执行指定程序,版本要求:PHP 4 >= 4.2.0, PHP 5
2、利用
在做渗透的时候被disable_functions卡住不能执行命令是家常便饭,今天在一国外虚拟主机上又被卡了,但我在执行phpinfo();的时候眼前闪过–enable-pcntl。当时我就偷笑了,没啥好说的,我一直强调渗透要细心做人做事也一样。
#exec.php
<?php cntl_exec(“/bin/bash”, array(“/tmp/b4dboy.sh”));?>
命令执行防御函数
escapeshellarg 转义
escapeshellcmd() 转义
然而escapeshellcmd()和escapeshellarg一起使用,会造成特殊字符逃逸
参考:https://paper.seebug.org/164/
网友评论