码迷,mamicode.com
首页 > Web开发 > 详细

php直接执行linux 命令

时间:2018-05-02 11:19:35      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:lang   www   lin   local   ref   tput   div   netstat   返回   

注意你可以使用的命令只能是php这个用户组的权限和范围,注意这个linux 执行的,windows也是可以对应dos命令,但是打印格式不是很好看

//$output = `ls -al`;
//$output = `netstat -tnlp`;
$output = `id www`;
echo "<pre>$output</pre>";

网页返回的结果

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1471/nginx          
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      -                   
tcp        0      0 :::3306                     :::*                        LISTEN      -                   
tcp        0      0 :::22                       :::*                        LISTEN      -                   
tcp        0      0 ::1:25                      :::*                        LISTEN      -      

linux root权限

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1470/nginx          
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1229/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1452/master         
tcp        0      0 :::3306                     :::*                        LISTEN      1348/mysqld         
tcp        0      0 :::22                       :::*                        LISTEN      1229/sshd           
tcp        0      0 ::1:25                      :::*                        LISTEN      1452/master    

可以明显看出

注意不是英文的单引号,是反引号(``)

这个可以作为注入的代码

这个叫做 执行运算符

http://php.net/manual/zh/language.operators.execution.php

你还可以通过  程序执行 相关的函数来执行程序

http://php.net/manual/zh/ref.exec.php

 

php直接执行linux 命令

标签:lang   www   lin   local   ref   tput   div   netstat   返回   

原文地址:https://www.cnblogs.com/zx-admin/p/8978867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!