美文网首页
SUCTF 2019 WriteUp

SUCTF 2019 WriteUp

作者: Eumenides_62ac | 来源:发表于2019-10-02 20:48 被阅读0次

    Web

    Misc

    签到题

    给了一串编码,制作:

    <img src="data:image/png;base64,[给的编码]">
    

    打开网页就可以得到flag

    game

    查看源代码得到:


    base32解密是一个假的flag

    /js/three.min.js里可以找到一个图片:iZwz9i9xnerwj6o7h40eauZ.png

    在图片的lsb隐写里可以发现信息:U2FsdGVkX1+zHjSBeYPtWQVSwXzcVFZLu6Qm0To/KeuHg8vKAxFrVQ==

    3DES的加密密文,找个在线网站解密即可得到flag,密钥是之前假的flag

    protocol

    使用binwalk分析下流量包,可以看到很多png图片:

    foremost命令分解得到一大堆图片:

    重新审计流量包,发现传输每张图片的流量的数据部分第3个字节有一定的变化规律,遂将该字节相同的空白图片与字符图片一一对应,即得flag

    Web

    checkIn

    一个上传点:


    限制了上传php,还不允许出现<?,还判断上传的文件头。
    过滤了.htaccess,这里需要用到.user.ini来构造PHP后门。
    构造去包含1.gif

    再上传1.gif

    访问/uploads/9c1534b1e8dbb5a0c0ec3f70d24f9627/
    成功被执行:

    获得flag


    easy_sql

    有个非预期解,存在.index.php.swp

    <?php
        session_start();
    
        include_once "config.php";
    
        $post = array();
        $get = array();
        global $MysqlLink;
    
        //GetPara();
        $MysqlLink = mysqli_connect("localhost",$datauser,$datapass);
        if(!$MysqlLink){
            die("Mysql Connect Error!");
        }
        $selectDB = mysqli_select_db($MysqlLink,$dataName);
        if(!$selectDB){
            die("Choose Database Error!");
        }
    
        foreach ($_POST as $k=>$v){
            if(!empty($v)&&is_string($v)){
                $post[$k] = trim(addslashes($v));
            }
        }
        foreach ($_GET as $k=>$v){
            }
        }
        //die();
        ?>
    
    <html>
    <head>
    </head>
    
    <body>
    
    <a> Give me your flag, I will tell you if the flag is right. </ a>
    <form action="" method="post">
    <input type="text" name="query">
    <input type="submit">
    </form>
    </body>
    </html>
    
    <?php
    
        if(isset($post['query'])){
            $BlackList = "prepare|flag|unhex|xml|drop|create|insert|like|regexp|outfile|readfile|where|from|union|update|delete|if|sleep|extractvalue|updatexml|or|and|&|\"";
            //var_dump(preg_match("/{$BlackList}/is",$post['query']));
            if(preg_match("/{$BlackList}/is",$post['query'])){
                //echo $post['query'];
                die("Nonono.");
            }
            if(strlen($post['query'])>40){
                die("Too long.");
            }
            $sql = "select ".$post['query']."||flag from Flag";
            mysqli_multi_query($MysqlLink,$sql);
            do{
                if($res = mysqli_store_result($MysqlLink)){
                    while($row = mysqli_fetch_row($res)){
                        print_r($row);
                    }
                }
            }while(@mysqli_next_result($MysqlLink));
    
        }
    
        ?>
    

    可以看到有个管道符限制,非预期为:


    预期解涉及到了MYSQL一种管道符模式。
    可以在MYSQL中开启支持管道符来进行字符串的拼接操作:

    > set sql_mode=pipes_as_concat;
    

    如下:
    先在数据库准备一些测试数据:


    尝试添加||,只是当作操作符。

    如果开启模式后,可以看下效果:

    可以看到把id里的内容也给输出出来了。

    看一下最终查询的语句:

    $sql = "select ".$post['query']."||flag from Flag";
    

    构造payload1;set sql_mode=pipes_as_concat;select 1

    非预期也比较好理解:


    Upload labs 2

    相关文章

      网友评论

          本文标题:SUCTF 2019 WriteUp

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