2022长城杯awdplus
admin_page
登录处用户名参数存在注入,直接写马读取flag即可
防御,addslashes
:
|
|
numflask
flask ssti,但是题目没给源码,需要通过获取shell后得到源码提交修复补丁
通过黑盒测试发现过滤了数字和.等字符
bypass,寻找到os模块执行命令:
|
|
获取到flag和源码:
源码:
|
|
防御,去除{}
:
|
|
codeinlog
application/controllers/Upload.php
上传文件到application/cache/upload.log,读取并输出,所以这里看起来是安全的
application/controllers/Welcome.php
存在风险:可以传入phar触发反序列化
漏洞修复:
直接过滤phar://
|
|
防御成功,拿到防御分值
攻击分值现场队伍0解,赛后复现了一下
pop链挖掘:
全局搜索__destruc
t起点,找到:
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php->CacheAdapter->__destruct
|
|
定位到:
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php->CacheAdapter->commit
|
|
$key
和$item
均来自$this->deferredItems,$this->deferredItems
成员变量可控
全局搜索可利用的save方法,找到:
system/libraries/Cache/Cache.php->CI_Cache->save
|
|
$this->_adapter
可控,且父类CI_Driver_Library
存在__get
方法,发现可以通过传入的$this->_adapter
加载并实例化指定的类
system/libraries/Driver.php->CI_Driver_Library->__get->load_driver
|
|
所以这里可以将$this->_adapter
设为file,加载system/libraries/Cache/drivers/Cache_file.php,调用CI_Cache_file
类的save
方法,写入webshell
|
|
回到:
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php->CacheAdapter->commit
如何通过$this->deferredItems
控制写入的文件路径和内容?
文件路径写入位置为:APPPATH.'cache/'
:application/cache
可以设置写入路径为../../xxx.php,写入根目录
文件内容来自$item->get()
,全局搜索get
方法,找到:
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheItem.php->get
|
|
$this->value
可以设置成文件内容,通过get
获取到
pop链构造:
|
|