题目来源:极客大挑战 2019 题目名称:BuyFlag 1

0、打开网页,查看内容

在MENU菜单中有一个PAYFLAG页面
1、查看FLAG页面中的内容

If you want to buy the FLAG: You must be a student from CUIT!!! You must be answer the correct password!!!
Only Cuit’s students can buy the FLAG
提示需要以Cuit(Chengdu University of Information Technology)学生的身份登录而且要输入正确的密码
2、使用Ctrl + U查看源代码
<!DOCTYPE HTML>
<html>
<head>
<title>Buy You Flag</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body>
<div id="page-wrapper">
<header id="header">
<h1><a href="index.php">Syclover</a></h1>
<nav id="nav">
<ul>
<li class="special">
<a href="#menu" class="menuToggle"><span>Menu</span></a>
<div id="menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="pay.php">PayFlag</a></li>
</ul>
</div>
</li>
</ul>
</nav>
</header>
<article id="main">
<header>
<h2>Flag</h2>
<p>Flag need your 100000000 money</p>
</header>
<section class="wrapper style5">
<div class="inner">
<h3>attention</h3>
<p>If you want to buy the FLAG:</br>
You must be a student from CUIT!!!</br>
You must be answer the correct password!!!
</p>
<hr />
<p>
Only Cuit's students can buy the FLAG</br>
</p>
<hr />
</div>
</section>
</article>
<footer id="footer">
<ul class="copyright">
<li>© Syclover</li><li>Design: Cl4y</li>
</ul>
</footer>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
3、PHP代码审计
if (isset($_POST['password'])) {
$password = $_POST['password'];
if (is_numeric($password)) {
echo "password can't be number</br>";
}elseif ($password == 404) {
echo "Password Right!</br>";
}
}
isset()函数是用来检验变量是否被设置的。 is_numeric()函数检测字符串是否只由数字组成,如果字符串中只包括数字,就返回Ture,否则返回False。
对于$password == 404 ,在PHP中== 是一种弱类型比较,即只取字符串中开头的整数部分进行比较。
由此我们可以得出绕过密码的方法: ??用POST方法发送一个名为password 的变量,令password = 404a (在404后面添加任意字母即可)或password = 404%20 (相当于在404后面加了一个空格,其他空白字符也可以绕过)
注意到源代码中还有这样一句:Flag need your 100000000 money 也就是说我们还需要用POST方法上传money变量使其等于100000000
4、使用BurpSuite进行抓包
 在Request请求中,Cookie: user=0 ,这里是身份判断的位置,在布尔值中0为false,1为true,我们将其改为Cookie: user=1 以通过身份验证。  之后用POST方法发送password=404a  密码成功绕过,提示我们购买flag,也就是修改money的值,尝试直接上传  显示Nember lenth is too long 应该是存在长度限制,这里有两种绕过方法 1、科学计数法绕过money=1e9 2、数组绕过money[]=1  
5、得到flag:flag{5f443eb3-92b8-4a61-ab08-bc24e18ac369}
|