[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

相关推荐
selt7911 小时前
Redisson之RedissonLock源码完全解析
android·java·javascript
Yao_YongChao2 小时前
Android MVI处理副作用(Side Effect)
android·mvi·mvi副作用
非凡ghost3 小时前
JRiver Media Center(媒体管理软件)
android·学习·智能手机·媒体·软件需求
席卷全城3 小时前
Android 推箱子实现(引流文章)
android
齊家治國平天下3 小时前
Android 14 系统中 Tombstone 深度分析与解决指南
android·crash·系统服务·tombstone·android 14
maycho1235 小时前
MATLAB环境下基于双向长短时记忆网络的时间序列预测探索
android
思成不止于此5 小时前
【MySQL 零基础入门】MySQL 函数精讲(二):日期函数与流程控制函数篇
android·数据库·笔记·sql·学习·mysql
brave_zhao6 小时前
达梦数据库(DM8)支持全文索引功能,但并不直接兼容 MySQL 的 FULLTEXT 索引语法
android·adb
sheji34166 小时前
【开题答辩全过程】以 基于Android的网上订餐系统为例,包含答辩的问题和答案
android
easyboot6 小时前
C#使用SqlSugar操作mysql数据库
android·sqlsugar