Skip to content

Commit 55ef5dd

Browse files
committed
Land rapid7#3115, @silascutler's module for elasticsearch indeces enumeration
2 parents 69e8286 + 2271afc commit 55ef5dd

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Auxiliary::Scanner
12+
include Msf::Auxiliary::Report
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'ElasticSearch Indeces Enumeration Utility',
17+
'Description' => %q{
18+
This module enumerates ElasticSearch Indeces. It uses the REST API
19+
in order to make it.
20+
},
21+
'Author' =>
22+
[
23+
'Silas Cutler <Silas.Cutler[at]BlackListThisDomain.com>'
24+
],
25+
'License' => MSF_LICENSE
26+
))
27+
28+
register_options(
29+
[
30+
Opt::RPORT(9200)
31+
], self.class)
32+
end
33+
34+
def peer
35+
"#{rhost}:#{rport}"
36+
end
37+
38+
def run_host(ip)
39+
vprint_status("#{peer} - Querying indeces...")
40+
begin
41+
res = send_request_raw({
42+
'uri' => '/_aliases',
43+
'method' => 'GET',
44+
})
45+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable
46+
vprint_error("#{peer} - Unable to establish connection")
47+
return
48+
end
49+
50+
if res && res.code == 200 && res.body.length > 0
51+
begin
52+
json_body = JSON.parse(res.body)
53+
rescue JSON::ParserError
54+
vprint_error("#{peer} - Unable to parse JSON")
55+
return
56+
end
57+
else
58+
vprint_error("#{peer} - Timeout or unexpected response...")
59+
return
60+
end
61+
62+
report_service(
63+
:host => rhost,
64+
:port => rport,
65+
:proto => 'tcp',
66+
:name => 'elasticsearch'
67+
)
68+
69+
indeces = []
70+
71+
json_body.each do |index|
72+
indeces.push(index[0])
73+
report_note(
74+
:host => rhost,
75+
:port => rport,
76+
:proto => 'tcp',
77+
:type => "elasticsearch.index",
78+
:data => index[0],
79+
:update => :unique_data
80+
)
81+
end
82+
83+
if indeces.length > 0
84+
print_good("#{peer} - ElasticSearch Indeces found: #{indeces.join(", ")}")
85+
end
86+
87+
end
88+
89+
end

0 commit comments

Comments
 (0)