i春秋 “百度杯”CTF比赛 十月场 Login

版权声明:欢迎提问:[email protected] https://blog.csdn.net/include_heqile/article/details/82749864

https://www.ichunqiu.com/battalion?t=1&r=0

这道题还是比较狗的

首先进入题目链接,查看源代码,发现注释掉的提示<!-- test1 test1 -->

使用该账号和用户名登陆进去,发现一个掀桌的表情(╯‵□′)╯︵┴─┴

查看源代码,没有任何提示,使用burp suite抓包,查看http报头中的字段,发现一个可疑字段show
在这里插入图片描述

现在我们在自己的请求包中加上该字段。并改变它的值,尝试改成1,结果有重大发现,我们得到了member.php的源代码,查看一下代码:

<?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');
	}

?> 

我们直接构造一个数组:

$test = array("user" => "ichunqiu")

然后base64_encode(gzcompress(serialize($test)))

将得到的结果放入构造的请求中的Cookietoken字段中
在这里插入图片描述

这样就能得到flag

猜你喜欢

转载自blog.csdn.net/include_heqile/article/details/82749864