[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

相关推荐
wenzhangli730 分钟前
在低代码设计中践行 Harness Engineering
android·低代码·rxjava
xingpanvip1 小时前
星盘接口开发文档:组合三限盘接口指南
android·开发语言·前端·python·php·lua
TechMix2 小时前
【fkw学习笔记】Android 13 AOSP 源码添加系统预置应用实战指南
android·笔记·学习
云起SAAS2 小时前
私域直播系统UniApp源码 多商户商城+直播带货 微信小程序+H5+安卓iOS
android·微信小程序·uni-app·私域直播系统
空中海2 小时前
01. 安卓逆向基础、环境搭建与授权
android
星河耀银海2 小时前
JAVA 泛型与通配符:从原理到实战应用
android·java·服务器
Ada大侦探3 小时前
新手小白学习数据分析01----数据分析师???& 数据分析思维学习
android·学习·数据分析
空中海3 小时前
安卓逆向5. 安卓风险防护、加固复测与综合
android
Mr -老鬼3 小时前
EasyClick 双端自动化智能体|Android&iOS 全平台 EC 脚本开发助手
android·ios·自动化·易点云测·#easyclick·#ios自动化
千码君20163 小时前
flutter:与Android Studio模拟器的调试分享
android·flutter