0%

Miac2017第二轮Writeup

WEB

签到题

查看源代码
<input type="text" maxlength="3" name="pass"/>
提示输入更大的数,并限制了text的maxlength,F12修改html,删除maxlength部分.

简单的题

查看源代码,给出了部分php,审计。

1
2
3
4
5
if(isset($_POST['password'])) {
if (strcmp($_POST['password'], $flag) == 0)
die($flag);
else
echo "密码不正确!";

strcmp可以直接用数组绕过,将password改为数组即可。

WEB100-2

提示?hint,随便尝试一下,?hint=1,显示了源码。

核心部分。

1
2
3
4
5
6
7
8
9
10
11
12
$KEY='BDCTF:www.bluedon.com'; 
include_once("flag.php");

$cookie = $_COOKIE['BDCTF'];

if(isset($_GET['hint'])){
show_source(__FILE__);
}
elseif (unserialize($cookie) === "$KEY")
{
echo "$flag";
}

将key的值序列化放在cookie的BDCTF变量中即可。

送大礼

访问flag.txt,解jsfuck得到

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extract($_GET);  
if(isset($bdctf))
{
$content=trim(file_get_contents($flag));
if($bdctf==$content)
{
echo'bdctf{**********}';
}
else
{
echo'这不是蓝盾的密码啊';
}
}
}

变量覆盖漏洞。

蓝盾管理员

部分php源码

1
2
3
4
5
6
7
8
9
@$user = $_GET["user"];  
@$file = $_GET["file"];

if(isset($user)&&(file_get_contents($user,'r')==="the user is bdadmin")){
echo "hello bd-admin!<br>";
include($file); //flag.php
}else{
echo "you are not bd-admin ! ";
}

用php伪协议php://input绕过file_get_contents($user,'r')==="the user is bdadmin"

然后可以直接用file变量的伪协议读取file.php

bluedon用户

与蓝盾管理员类似,不过读取的是class.php

1
2
3
4
5
6
7
8
9
10
11
<?php
class Read{//f1a9.php
public $file;
public function __toString(){
if(isset($this->file)){
echo file_get_contents($this->file);
}
return "恭喜get flag";
}
}
?>

index.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
@$user = $_GET["user"];
@$file = $_GET["file"];
@$pass = $_GET["pass"];

if(isset($user)&&(file_get_contents($user,'r')==="the user is bluedon")){
echo "hello bluedon!<br>";
if(preg_match("/f1a9/",$file)){
exit();
}else{
@include($file); //class.php
$pass = unserialize($pass);
echo $pass;
}
}else{
echo "you are not bluedon ! ";
}

?>

<!--
$user = $_GET["user"];
$file = $_GET["file"];
$pass = $_GET["pass"];

if(isset($user)&&(file_get_contents($user,'r')==="the user is bluedon")){
echo "hello bluedon!<br>";
include($file); //class.php
}else{
echo "you are not bluedon ! ";
}
-->

不能直接读取f1a9,但是可以用反序列化读取。

O:4:"Read":1:{s:4:"file";s:57:"php://filter/read=convert.base64-encode/resource=f1a9.php";}

MISC

杂项全家桶

解压出一张损坏的png图片,16进制打开发现没有文件头,将文件头补全89 50 4E 47 0D 0A 1A 0A,得到一张二维码,扫描二维码,得到工井大人夫王

当铺密码,解密得485376

对png图片分析,发现png图片还有一个rar的压缩包,里面是一个MP3,猜测是MP3Stego隐写,密码就是解出的数字。

decode.exe -X music.mp3 -P 485376得到fx4qx0hj_4_cg{Wvf}

应该是栅栏和凯撒密码的结合,解栅栏密码fhgxj{4_Wq4vx_f0c},猜测前面是bdctf,用凯撒解密得到flag。

bdctf{4_Sm4rt_b0y}

Stega

像素隐藏

zip压缩包为伪加密,直接修改0400后面的为0000即可解压出图片。

图片没有隐藏内容,发现有透明框,修改图片的高度得到flag。