php直接執行linux 命令


注意你可以使用的命令只能是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

 

 

如果ajax訪問api發現有小紅點印象json格式

1,可能是文件utf-8 和utf-8 bom

2,ob_clean 強制清除

3,查看php解析符,之前有什么東西 <?php     

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM