@@ -13,47 +13,77 @@ class Metasploit3 < Msf::Auxiliary
13
13
14
14
def initialize ( info = { } )
15
15
super ( update_info ( info ,
16
- 'Name' => 'ElasticSearch Enum Utility' ,
17
- 'Description' => %q{ Send a request to enumerate ElasticSearch indices} ,
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
+ } ,
18
21
'Author' =>
19
22
[
20
- 'Silas Cutler <Silas.Cutler [at] BlackListThisDomain.com>'
23
+ 'Silas Cutler <Silas.Cutler[at]BlackListThisDomain.com>'
21
24
] ,
22
25
'License' => MSF_LICENSE
23
26
) )
24
-
27
+
25
28
register_options (
26
29
[
27
30
Opt ::RPORT ( 9200 )
28
31
] , self . class )
29
32
end
30
33
34
+ def peer
35
+ "#{ rhost } :#{ rport } "
36
+ end
37
+
31
38
def run_host ( ip )
39
+ vprint_status ( "#{ peer } - Querying indeces..." )
32
40
begin
33
41
res = send_request_raw ( {
34
42
'uri' => '/_aliases' ,
35
43
'method' => 'GET' ,
36
44
} )
37
-
38
- begin
39
- json_body = JSON . parse ( res . body )
40
- rescue JSON ::ParserError
41
- print_error ( "Unable to parse JSON" )
45
+ rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable
46
+ vprint_error ( "#{ peer } - Unable to establish connection" )
42
47
return
43
48
end
44
49
45
- if res and res . code == 200 and res . body . length > 0
46
- json_body . each do |index |
47
- print_good ( "Index : " + index [ 0 ] )
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
48
56
end
49
-
50
- path = store_loot ( "elasticsearch.enum.file" , "text/plain" , ip , res . body , "ElasticSearch Enum Results" )
51
- print_good ( "Results saved to #{ path } " )
52
57
else
53
- print_error ( "Failed to save the result" )
58
+ vprint_error ( "#{ peer } - Timeout or unexpected response..." )
59
+ return
54
60
end
55
61
56
- rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable
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
+ )
57
81
end
82
+
83
+ if indeces . length > 0
84
+ print_good ( "#{ peer } - ElasticSearch Indeces found: #{ indeces . join ( ", " ) } " )
85
+ end
86
+
58
87
end
88
+
59
89
end
0 commit comments