Skip to content

Commit d361597

Browse files
committed
Update es_enum.rb
1 parent ad4c354 commit d361597

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

modules/auxiliary/scanner/elasticsearch/es_enum.rb

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,57 @@
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
55

6-
76
require 'msf/core'
87

9-
108
class Metasploit3 < Msf::Auxiliary
119

12-
# Exploit mixins should be called first
1310
include Msf::Exploit::Remote::HttpClient
14-
# Scanner mixin should be near last
1511
include Msf::Auxiliary::Scanner
1612
include Msf::Auxiliary::Report
1713

18-
def initialize
19-
super(
20-
'Name' => 'ElasticSearch Enum Utility',
21-
'Description' => 'Send a request to enumerate ElasticSearch indices',
22-
'Author' => ['Silas Cutler <Silas.Cutler [at] BlackListThisDomain.com'],
23-
'License' => MSF_LICENSE
24-
)
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'ElasticSearch Enum Utility',
17+
'Description' => %q{ Send a request to enumerate ElasticSearch indices},
18+
'Author' =>
19+
[
20+
'Silas Cutler <Silas.Cutler [at] BlackListThisDomain.com>'
21+
],
22+
'License' => MSF_LICENSE
23+
))
24+
2525
register_options(
2626
[
2727
Opt::RPORT(9200)
28-
]
29-
)
30-
28+
], self.class)
3129
end
3230

33-
def run_host(target_host)
34-
31+
def run_host(ip)
3532
begin
3633
res = send_request_raw({
3734
'uri' => '/_aliases',
3835
'method' => 'GET',
3936
'version' => '1.0',
4037
}, 10)
4138

42-
if res.nil?
43-
print_error("No response for #{target_host}")
44-
return nil
45-
end
46-
4739
begin
48-
temp = JSON.parse(res.body)
40+
json_body = JSON.parse(res.body)
4941
rescue JSON::ParserError
5042
print_error("Unable to parse JSON")
5143
return
5244
end
5345

54-
55-
if (res.code == 200)
56-
temp.each do |index|
46+
if res and res.code == 200 and res.body.length > 0
47+
json_body.each do |index|
5748
print_good("Index : " + index[0])
5849
end
59-
end
6050

61-
if res and res.code == 200 and res.headers['Content-Type'] and res.body.length > 0
62-
path = store_loot("elasticsearch.enum.file", "text/plain", rhost, res.body, "ElasticSearch Enum Results")
63-
print_status("Results saved to #{path}")
51+
path = store_loot("elasticsearch.enum.file", "text/plain", ip, res.body, "ElasticSearch Enum Results")
52+
print_good("Results saved to #{path}")
6453
else
6554
print_error("Failed to save the result")
6655
end
6756

68-
6957
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
7058
rescue ::Timeout::Error, ::Errno::EPIPE
7159
end

0 commit comments

Comments
 (0)