[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

相关推荐
2501_9159214310 分钟前
iOS 上架 App Store 常见 ITMS 报错排查,哪些需要修改哪些是警告
android·ios·小程序·https·uni-app·iphone·webview
默 语1 小时前
【HarmonyOS7】ArkTS通用属性实战(一):一文吃透尺寸设置 width/height/size
android
开发者导航1 小时前
Cursor plugins 插件仓库上手:结构解析与安装使用教程
android·linux·ubuntu·ai·typescript·cursor·插件开发
大数据女孩_Aimee4 小时前
安卓15CTS:CtsCompilationTestCases模块测试FAIL
android·模块测试
箓维18 小时前
MySQL_表的约束
android·数据库·mysql
HEJOO921 小时前
MySQL 日期时间类型怎么选:DATE、DATETIME、TIMESTAMP、TIME、YEAR 全解析
android·数据库·mysql
风早爽太1 天前
Android 开发笔记:封装 Fragment 的管理工具类
android·kotlin
峥嵘life1 天前
Android 17 具体代码新特性总结
android·开发语言·网络
王者鳜錸1 天前
Android 接入 AIKit 轻量版语音合成实战
android·交互·多语种·离线合成·多种发音人
『 时光荏苒 』1 天前
SQL 中常用的查询条件分类汇总,每个都配有“大白话注释”和示例,方便你对照学习
android·java·开发语言