任意文件下载
知识点
- 目录扫描
- 任意文件下载
打开网页后,未发现任何提示信息,直接上扫描(其实是想了很久才想出来的),扫描后发现有以下几个目录。
首先打开robots.txt,发现提示download777.php
打开download777.php,发现提示filename不能为空,直接输入get变量filename
输入filename后,发现直接将index.php下载下来了。
果断先将download777.php下载下来,代码如下
<?php
$filename = $_GET['filename'];
$file = $filename;
if(!empty($file)){
//First, see if the file exists
if (!is_file($file)) { die("<b>404 File not found!</b>"); }
//Gather relevent info about file
//$len = filesize($file);
//此处为任意文件下载漏洞
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
$content = file_get_contents($file);
header("Content-Disposition: inline; filename=$filename");
header("Content-type: application/".$file_extension."");
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
echo $content;
}else{
echo "filename can't null";
}
?>
代码审计后发现只有一个任意文件下载的代码,没有其他可用信息了,再次下载其他的php,想到之前的扫描信息,info.php,发现代码为
<?php
//include "testconfig.inc.php";
?>
发现还有一个文件testconfig.inc.php,下载testconfig.inc.php,获得flag