metasploit-framework/modules/auxiliary/scanner/elasticsearch/indeces_enum.rb

96 lines
2.2 KiB
Ruby
Raw Normal View History

2014-03-17 17:31:24 +00:00
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
2014-05-29 22:38:01 +00:00
require 'msf/core/module/deprecated'
2014-03-17 17:31:24 +00:00
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
2014-05-29 22:38:01 +00:00
include Msf::Module::Deprecated
DEPRECATION_DATE = Date.new(2014, 07, 29)
DEPRECATION_REPLACEMENT = 'auxiliary/scanner/elasticsearch/indices_enum'
2014-03-18 13:20:04 +00:00
def initialize(info = {})
super(update_info(info,
2014-05-29 17:37:51 +00:00
'Name' => 'ElasticSearch Indices Enumeration Utility',
2014-05-27 16:22:40 +00:00
'Description' => %q{
2014-05-29 17:37:51 +00:00
This module enumerates ElasticSearch Indices. It uses the REST API
2014-05-27 16:22:40 +00:00
in order to make it.
},
2014-03-18 13:20:04 +00:00
'Author' =>
[
2014-05-27 16:22:40 +00:00
'Silas Cutler <Silas.Cutler[at]BlackListThisDomain.com>'
2014-03-18 13:20:04 +00:00
],
'License' => MSF_LICENSE
))
2014-05-27 16:22:40 +00:00
2014-03-17 17:31:24 +00:00
register_options(
2014-03-17 17:34:45 +00:00
[
2014-03-17 17:31:24 +00:00
Opt::RPORT(9200)
2014-03-18 13:20:04 +00:00
], self.class)
2014-03-17 17:31:24 +00:00
end
2014-05-27 16:22:40 +00:00
def peer
"#{rhost}:#{rport}"
end
2014-03-18 13:20:04 +00:00
def run_host(ip)
2014-05-29 17:37:51 +00:00
vprint_status("#{peer} - Querying indices...")
2014-03-17 17:31:24 +00:00
begin
res = send_request_raw({
'uri' => '/_aliases',
'method' => 'GET',
})
2014-05-27 16:22:40 +00:00
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable
vprint_error("#{peer} - Unable to establish connection")
2014-03-17 17:31:24 +00:00
return
end
2014-05-27 16:22:40 +00:00
if res && res.code == 200 && res.body.length > 0
begin
json_body = JSON.parse(res.body)
rescue JSON::ParserError
vprint_error("#{peer} - Unable to parse JSON")
return
2014-03-17 17:31:24 +00:00
end
else
2014-05-27 16:22:40 +00:00
vprint_error("#{peer} - Timeout or unexpected response...")
return
2014-03-17 17:31:24 +00:00
end
2014-05-27 16:22:40 +00:00
report_service(
:host => rhost,
:port => rport,
:proto => 'tcp',
:name => 'elasticsearch'
)
2014-05-29 17:37:51 +00:00
indices = []
2014-05-27 16:22:40 +00:00
json_body.each do |index|
2014-05-29 17:37:51 +00:00
indices.push(index[0])
2014-05-27 16:22:40 +00:00
report_note(
:host => rhost,
:port => rport,
:proto => 'tcp',
:type => "elasticsearch.index",
:data => index[0],
:update => :unique_data
)
2014-03-17 17:31:24 +00:00
end
2014-05-27 16:22:40 +00:00
2014-05-29 17:37:51 +00:00
if indices.length > 0
print_good("#{peer} - ElasticSearch Indices found: #{indices.join(", ")}")
2014-05-27 16:22:40 +00:00
end
2014-03-17 17:31:24 +00:00
end
2014-05-27 16:22:40 +00:00
2014-03-17 17:31:24 +00:00
end