檔案包含漏洞一覽

2021-10-10 08:50:50 字數 2775 閱讀 1195

引起該漏洞的通常是

include()

include_once()

require()

require_once()

fopen()

readfile()

原理:當使用這幾個函式包含檔案時,不管檔案是什麼型別,都會作為php檔案解析

lfi 本地檔案包含漏洞

rfi 遠端檔案包含漏洞php偽協議

php.ini設定

php://input

php://input可以訪問請求的原始資料的唯讀流,將post請求的資料當作php**執行。當傳入的引數作為檔名開啟時,可以將引數設為php://input,同時post想設定的檔案內容,php執行時會將post內容當作檔案內容。

注:當enctype=」multipart/form-data」時,php://input是無效的。

姿勢:

1. index.php?file=php://filter/read=convert.base64-encode/resource=index.php

2. index.php?file=php://filter/convert.base64-encode/resource=index.php

通過指定末尾的檔案,可以讀取經base64加密後的檔案原始碼,之後再base64解碼一下就行。雖然不能直接獲取到shell等,但能讀取敏感檔案危害也是挺大的。

phar://

zip://(壓縮)

data:url schema

?file=data://text/plain;base64,base64編碼的payload

(需要allow_url_include=on)

1. index.php?file=data:text/plain,<?php phpinfo();?>

2. index.php?file=data:text/plain;base64,pd9wahagcghwaw5mbygpoz8%2b(base64編碼<?php phpinfo();?>,%2b的編碼+)

包含session

包含日誌

常見路徑

訪問日誌

ssh log參考

用ssh連線

在ssh-log寫入**

使用一句話作為使用者名稱,連線

包含environ

參考1

php以cgi方式執行,這樣environ才會保持ua頭。

environ檔案儲存位置已知,且environ檔案可讀。

包含fd參考

包含臨時檔案

包含上傳檔案指定字首

目錄遍歷

<?php 

$file = $_get['file'];

include '/var/www/'.$file;

?>

編碼繞過

指定字尾

<?php 

$file = $_get['file'];

include $file.'/test/test.php';

?>

利用query(加?)或者fragment(加#)

protocol :// hostname[:port] / path / [;parameters][?query]#fragment
利用協議

00截斷

長度截斷linux最大長度為4096,windows為256

0位元組截斷,php版本低於5.3.4

magic_quotes_gpc=off

路徑長度截斷

/etc/passwd/././././././.[…]/./././././.

(php版本小於5.2.8(?)可以成功,linux需要檔名長於4096,windows需要長於256)

點號截斷

/boot.ini/………[…]…………

(php版本小於5.2.8(?)可以成功,只適用windows,點號需要長於256)

php配置open_basedir做好檔案許可權

過濾危險字元

C 標頭檔案一覽

傳統 c include file 設定插入點 include file 字元處理 include file 定義錯誤碼 include file 浮點數處理 include file 檔案輸入 輸出 include file 引數化輸入 輸出 include file 資料流輸入 輸出 inclu...

C C 標頭檔案一覽

c 傳統 c include 設定插入點 include 字元處理 include 定義錯誤碼 include 浮點數處理 include 檔案輸入 輸出 include 引數化輸入 輸出 include 資料流輸入 輸出 include 定義各種資料型別最值常量 include 定義本地化函式 i...

C C 標頭檔案一覽

c 傳統 c include 設定插入點 include 字元處理 include 定義錯誤碼 include 浮點數處理 include 檔案輸入 輸出 include 引數化輸入 輸出 include 資料流輸入 輸出 include 定義各種資料型別最值常量 include 定義本地化函式 i...