[Zer0pts2020]Can you guess it?1

打开题目

看到信息随便输入一个数,显示错误

查看源代码

看到php代码,代码审计

<?php

include 'config.php'; // FLAG is defined in config.php

if (preg_match('/config\.php\/*/i', _SERVER['PHP_SELF'])) {

exit("I don't know what you are thinking, but I won't let you read it :)");

}

if (isset($_GET['source'])) {

highlight_file(basename($_SERVER['PHP_SELF']));

exit();

}

$secret = bin2hex(random_bytes(64));

if (isset($_POST['guess'])) {

guess = (string) _POST['guess'];

if (hash_equals(secret, guess)) {

$message = 'Congratulations! The flag is: ' . FLAG;

} else {

$message = 'Wrong.';

}

}

?>

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Can you guess it?</title>

</head>

<body>

<h1>Can you guess it?</h1>

<p>If your guess is correct, I'll give you the flag.</p>

<p><a href="?source">Source</a></p>

<hr>

<?php if (isset($message)) { ?>

<p><?= $message ?></p>

<?php } ?>

<form action="index.php" method="POST">

<input type="text" name="guess">

<input type="submit">

</form>

</body>

</html>

basename()

会返回路径重的文件名部分。比如/index.php/config.php使用basename()之后返回config.php
basename()会去掉文件名开头的非ASCII值。

看到提示,有config.php目录,跳转一下看看。

得到

我们要想访问config,但是config.php被正则过滤了

本题目利用的是basename()漏洞

用不可显字符绕过正则(后面加 %80 -- %ff 的任意字符)

我们构造payload:/index.php/config.php/%ff?source

访问得到flag

相关推荐
恋猫de小郭9 分钟前
来了解一下,为什么你的 Flutter WebView 在 iOS 26 上有点击问题?
android·前端·flutter
newchenxf28 分钟前
AndroidStudio版本和AGP版本和gradle版本以及kotlin gradle plugin版本关系梳理 2025
android·开发语言·kotlin
曹绍华2 小时前
kotlin扩展函数是如何实现的
android·开发语言·kotlin
LSL666_7 小时前
5 Repository 层接口
android·运维·elasticsearch·jenkins·repository
alexhilton11 小时前
在Jetpack Compose中创建CRT屏幕效果
android·kotlin·android jetpack
2501_9400940213 小时前
emu系列模拟器最新汉化版 安卓版 怀旧游戏模拟器全集附可运行游戏ROM
android·游戏·安卓·模拟器
下位子13 小时前
『OpenGL学习滤镜相机』- Day9: CameraX 基础集成
android·opengl
参宿四南河三14 小时前
Android Compose SideEffect(副作用)实例加倍详解
android·app
火柴就是我15 小时前
mmkv的 mmap 的理解
android
没有了遇见15 小时前
Android之直播宽高比和相机宽高比不支持后动态获取所支持的宽高比
android